{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/\n",
      "Requirement already satisfied: paddlepaddle-gpu in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (2.6.1)\n",
      "Requirement already satisfied: httpx in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (0.27.0)\n",
      "Requirement already satisfied: numpy>=1.13 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (2.0.0)\n",
      "Requirement already satisfied: Pillow in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (10.4.0)\n",
      "Requirement already satisfied: decorator in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (5.1.1)\n",
      "Requirement already satisfied: astor in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (0.8.1)\n",
      "Requirement already satisfied: opt-einsum==3.3.0 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (3.3.0)\n",
      "Requirement already satisfied: protobuf<=3.20.2,>=3.1.0 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddlepaddle-gpu) (3.20.2)\n",
      "Requirement already satisfied: anyio in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpx->paddlepaddle-gpu) (4.4.0)\n",
      "Requirement already satisfied: certifi in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpx->paddlepaddle-gpu) (2024.7.4)\n",
      "Requirement already satisfied: httpcore==1.* in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpx->paddlepaddle-gpu) (1.0.5)\n",
      "Requirement already satisfied: idna in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpx->paddlepaddle-gpu) (3.7)\n",
      "Requirement already satisfied: sniffio in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpx->paddlepaddle-gpu) (1.3.1)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from httpcore==1.*->httpx->paddlepaddle-gpu) (0.14.0)\n",
      "Requirement already satisfied: exceptiongroup>=1.0.2 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from anyio->httpx->paddlepaddle-gpu) (1.2.2)\n",
      "Requirement already satisfied: typing-extensions>=4.1 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from anyio->httpx->paddlepaddle-gpu) (4.12.2)\n",
      "Note: you may need to restart the kernel to use updated packages.\n",
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/\n",
      "Collecting paddleocr\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d8/c1/6af6262846c888285130839a9e570170e508a30e4ddeeef01b7ceabdcd92/paddleocr-2.8.0-py3-none-any.whl (407 kB)\n",
      "     ---------------------------------------- 0.0/407.3 kB ? eta -:--:--\n",
      "     --- --------------------------------- 41.0/407.3 kB 960.0 kB/s eta 0:00:01\n",
      "     ------------- ------------------------ 143.4/407.3 kB 2.1 MB/s eta 0:00:01\n",
      "     ------------------------- ------------ 276.5/407.3 kB 2.4 MB/s eta 0:00:01\n",
      "     -------------------------------------- 407.3/407.3 kB 2.8 MB/s eta 0:00:00\n",
      "Collecting shapely (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/70/a5/6d171586eb850c7582d2aeab027e1027ace4eb3a6c2e5f05746b8ab039e0/shapely-2.0.5-cp310-cp310-win_amd64.whl (1.4 MB)\n",
      "     ---------------------------------------- 0.0/1.4 MB ? eta -:--:--\n",
      "     - -------------------------------------- 0.1/1.4 MB ? eta -:--:--\n",
      "     --------- ------------------------------ 0.4/1.4 MB 5.5 MB/s eta 0:00:01\n",
      "     ------------------- -------------------- 0.7/1.4 MB 7.2 MB/s eta 0:00:01\n",
      "     ------------------------------- -------- 1.1/1.4 MB 7.9 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.4/1.4 MB 8.3 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 1.4/1.4 MB 3.3 MB/s eta 0:00:00\n",
      "Collecting scikit-image (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/99/89/3fcd68d034db5d29c974e964d03deec9d0fbf9410ff0a0b95efff70947f6/scikit_image-0.24.0-cp310-cp310-win_amd64.whl (12.9 MB)\n",
      "     ---------------------------------------- 0.0/12.9 MB ? eta -:--:--\n",
      "     - -------------------------------------- 0.4/12.9 MB 13.9 MB/s eta 0:00:01\n",
      "     - -------------------------------------- 0.6/12.9 MB 13.3 MB/s eta 0:00:01\n",
      "     -- ------------------------------------- 0.8/12.9 MB 7.3 MB/s eta 0:00:02\n",
      "     ----- ---------------------------------- 1.6/12.9 MB 11.7 MB/s eta 0:00:01\n",
      "     ------ --------------------------------- 2.1/12.9 MB 12.0 MB/s eta 0:00:01\n",
      "     ------- -------------------------------- 2.5/12.9 MB 11.4 MB/s eta 0:00:01\n",
      "     --------- ------------------------------ 2.9/12.9 MB 11.6 MB/s eta 0:00:01\n",
      "     ---------- ----------------------------- 3.3/12.9 MB 11.8 MB/s eta 0:00:01\n",
      "     ----------- ---------------------------- 3.7/12.9 MB 11.9 MB/s eta 0:00:01\n",
      "     ----------- ---------------------------- 3.7/12.9 MB 11.9 MB/s eta 0:00:01\n",
      "     -------------- ------------------------- 4.5/12.9 MB 11.6 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.4 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 5.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------- ----------------------- 5.2/12.9 MB 6.3 MB/s eta 0:00:02\n",
      "     ------------------------------ --------- 9.9/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ --------- 9.9/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 10.3/12.9 MB 10.9 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 11.2/12.9 MB 11.9 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 11.6/12.9 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 12.0/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 12.4/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  12.8/12.9 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------- 12.9/12.9 MB 11.3 MB/s eta 0:00:00\n",
      "Collecting imgaug (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/66/b1/af3142c4a85cba6da9f4ebb5ff4e21e2616309552caca5e8acefe9840622/imgaug-0.4.0-py2.py3-none-any.whl (948 kB)\n",
      "     ---------------------------------------- 0.0/948.0 kB ? eta -:--:--\n",
      "     ----------------- ------------------- 440.3/948.0 kB 13.4 MB/s eta 0:00:01\n",
      "     ----------------------- ------------- 604.2/948.0 kB 12.6 MB/s eta 0:00:01\n",
      "     -------------------------------- ----- 809.0/948.0 kB 8.5 MB/s eta 0:00:01\n",
      "     -------------------------------------- 948.0/948.0 kB 7.5 MB/s eta 0:00:00\n",
      "Collecting pyclipper (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/60/61/354f484ab7969a601327646bbaeb1b799508b4e81946ea4d52bbf9d779c6/pyclipper-1.3.0.post5-cp310-cp310-win_amd64.whl (108 kB)\n",
      "     ---------------------------------------- 0.0/108.2 kB ? eta -:--:--\n",
      "     -------------------------------------- 108.2/108.2 kB 6.1 MB/s eta 0:00:00\n",
      "Collecting lmdb (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/64/ca/5e8ed72930c410eedd25d801c8abfd6cbf65bac0461128fbdd03358b279e/lmdb-1.5.1-cp310-cp310-win_amd64.whl (100 kB)\n",
      "     ---------------------------------------- 0.0/100.3 kB ? eta -:--:--\n",
      "     ---------------------------------------- 100.3/100.3 kB ? eta 0:00:00\n",
      "Collecting tqdm (from paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/18/eb/fdb7eb9e48b7b02554e1664afd3bd3f117f6b6d6c5881438a0b055554f9b/tqdm-4.66.4-py3-none-any.whl (78 kB)\n",
      "Collecting numpy<2.0 (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/19/77/538f202862b9183f54108557bfda67e17603fc560c384559e769321c9d92/numpy-1.26.4-cp310-cp310-win_amd64.whl (15.8 MB)\n",
      "     ---------------------------------------- 0.0/15.8 MB ? eta -:--:--\n",
      "     - -------------------------------------- 0.4/15.8 MB 13.9 MB/s eta 0:00:02\n",
      "     - -------------------------------------- 0.6/15.8 MB 12.2 MB/s eta 0:00:02\n",
      "     -- ------------------------------------- 0.8/15.8 MB 7.3 MB/s eta 0:00:03\n",
      "     ---- ----------------------------------- 1.7/15.8 MB 11.9 MB/s eta 0:00:02\n",
      "     ----- ---------------------------------- 2.1/15.8 MB 11.2 MB/s eta 0:00:02\n",
      "     ------ --------------------------------- 2.5/15.8 MB 11.6 MB/s eta 0:00:02\n",
      "     ------- -------------------------------- 3.0/15.8 MB 11.8 MB/s eta 0:00:02\n",
      "     -------- ------------------------------- 3.4/15.8 MB 11.4 MB/s eta 0:00:02\n",
      "     --------- ------------------------------ 3.7/15.8 MB 11.7 MB/s eta 0:00:02\n",
      "     --------- ------------------------------ 3.8/15.8 MB 10.4 MB/s eta 0:00:02\n",
      "     ----------- ---------------------------- 4.6/15.8 MB 11.3 MB/s eta 0:00:01\n",
      "     ------------ --------------------------- 5.0/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------- -------------------------- 5.5/15.8 MB 11.7 MB/s eta 0:00:01\n",
      "     -------------- ------------------------- 5.9/15.8 MB 11.4 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 6.3/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------- ---------------------- 6.7/15.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ----------------- ---------------------- 6.7/15.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------- -------------------- 7.5/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     -------------------- ------------------- 8.0/15.8 MB 11.6 MB/s eta 0:00:01\n",
      "     --------------------- ------------------ 8.4/15.8 MB 11.4 MB/s eta 0:00:01\n",
      "     ---------------------- ----------------- 8.8/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------------- ---------------- 9.2/15.8 MB 11.6 MB/s eta 0:00:01\n",
      "     ------------------------ --------------- 9.7/15.8 MB 11.4 MB/s eta 0:00:01\n",
      "     ------------------------ --------------- 9.8/15.8 MB 11.4 MB/s eta 0:00:01\n",
      "     ------------------------ -------------- 10.1/15.8 MB 11.1 MB/s eta 0:00:01\n",
      "     -------------------------- ------------ 10.9/15.8 MB 11.9 MB/s eta 0:00:01\n",
      "     --------------------------- ----------- 11.3/15.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ---------------------------- ---------- 11.7/15.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ----------------------------- --------- 12.2/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 12.6/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 12.9/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 12.9/15.8 MB 10.9 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 13.8/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 14.2/15.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 14.7/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 15.1/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  15.5/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  15.8/15.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------- 15.8/15.8 MB 11.3 MB/s eta 0:00:00\n",
      "Collecting rapidfuzz (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/50/09/47b6540d026eafe44d37f01d2e37fbcf31ed02c29edcaa38862c238ec961/rapidfuzz-3.9.4-cp310-cp310-win_amd64.whl (1.6 MB)\n",
      "     ---------------------------------------- 0.0/1.6 MB ? eta -:--:--\n",
      "     ------------ --------------------------- 0.5/1.6 MB 15.4 MB/s eta 0:00:01\n",
      "     ----------------------- ---------------- 0.9/1.6 MB 11.8 MB/s eta 0:00:01\n",
      "     --------------------------------- ------ 1.4/1.6 MB 12.2 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 1.6/1.6 MB 11.3 MB/s eta 0:00:00\n",
      "Collecting opencv-python (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/6c/fab8113424af5049f85717e8e527ca3773299a3c6b02506e66436e19874f/opencv_python-4.10.0.84-cp37-abi3-win_amd64.whl (38.8 MB)\n",
      "     ---------------------------------------- 0.0/38.8 MB ? eta -:--:--\n",
      "     ---------------------------------------- 0.4/38.8 MB 13.4 MB/s eta 0:00:03\n",
      "      --------------------------------------- 0.6/38.8 MB 13.3 MB/s eta 0:00:03\n",
      "      --------------------------------------- 0.8/38.8 MB 8.7 MB/s eta 0:00:05\n",
      "     - -------------------------------------- 1.7/38.8 MB 11.8 MB/s eta 0:00:04\n",
      "     -- ------------------------------------- 2.1/38.8 MB 12.0 MB/s eta 0:00:04\n",
      "     -- ------------------------------------- 2.2/38.8 MB 12.5 MB/s eta 0:00:03\n",
      "     -- ------------------------------------- 2.2/38.8 MB 12.5 MB/s eta 0:00:03\n",
      "     -- ------------------------------------- 2.2/38.8 MB 12.5 MB/s eta 0:00:03\n",
      "     -- ------------------------------------- 2.2/38.8 MB 12.5 MB/s eta 0:00:03\n",
      "     -- ------------------------------------- 2.2/38.8 MB 12.5 MB/s eta 0:00:03\n",
      "     ---- ----------------------------------- 4.5/38.8 MB 11.6 MB/s eta 0:00:03\n",
      "     ----- ---------------------------------- 5.0/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ----- ---------------------------------- 5.4/38.8 MB 11.8 MB/s eta 0:00:03\n",
      "     ----- ---------------------------------- 5.8/38.8 MB 11.6 MB/s eta 0:00:03\n",
      "     ------ --------------------------------- 6.2/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ------ --------------------------------- 6.6/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ------ --------------------------------- 6.8/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ------- -------------------------------- 7.0/38.8 MB 10.9 MB/s eta 0:00:03\n",
      "     -------- ------------------------------- 7.8/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     -------- ------------------------------- 8.3/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     -------- ------------------------------- 8.7/38.8 MB 11.6 MB/s eta 0:00:03\n",
      "     --------- ------------------------------ 9.1/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     --------- ------------------------------ 9.5/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ---------- ----------------------------- 9.8/38.8 MB 11.6 MB/s eta 0:00:03\n",
      "     ---------- ----------------------------- 9.9/38.8 MB 11.1 MB/s eta 0:00:03\n",
      "     ---------- ---------------------------- 10.8/38.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 11.2/38.8 MB 11.9 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 11.6/38.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 12.0/38.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 12.4/38.8 MB 14.6 MB/s eta 0:00:02\n",
      "     ------------ -------------------------- 12.9/38.8 MB 13.6 MB/s eta 0:00:02\n",
      "     ------------ -------------------------- 12.9/38.8 MB 13.6 MB/s eta 0:00:02\n",
      "     ------------- ------------------------- 13.7/38.8 MB 12.8 MB/s eta 0:00:02\n",
      "     -------------- ------------------------ 14.1/38.8 MB 12.1 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 14.5/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 14.9/38.8 MB 11.7 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 15.4/38.8 MB 11.5 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 15.8/38.8 MB 11.5 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 15.9/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------- ---------------------- 16.2/38.8 MB 11.3 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 17.0/38.8 MB 12.1 MB/s eta 0:00:02\n",
      "     ----------------- --------------------- 17.5/38.8 MB 11.9 MB/s eta 0:00:02\n",
      "     ----------------- --------------------- 17.9/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------ -------------------- 18.3/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------ -------------------- 18.7/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 19.0/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 19.0/38.8 MB 11.1 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 19.9/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 20.4/38.8 MB 12.1 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 20.8/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 21.2/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 21.6/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 22.0/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 22.0/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 22.9/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 23.3/38.8 MB 11.9 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 23.7/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 24.1/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 24.6/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 25.0/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 25.1/38.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 25.4/38.8 MB 11.3 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 26.2/38.8 MB 12.1 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 26.7/38.8 MB 11.9 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 27.1/38.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 27.5/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------- ---------- 27.9/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------- ---------- 28.1/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------- ---------- 28.3/38.8 MB 11.1 MB/s eta 0:00:01\n",
      "     ----------------------------- --------- 29.1/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------------------- --------- 29.6/38.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 30.0/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 30.4/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 30.8/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 31.2/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 31.2/38.8 MB 11.1 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 32.1/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 32.5/38.8 MB 11.9 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 32.9/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 33.3/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 33.8/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 34.2/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 34.2/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 34.7/38.8 MB 11.1 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 35.4/38.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 35.8/38.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 36.2/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 36.7/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 37.1/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 37.3/38.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 37.5/38.8 MB 11.1 MB/s eta 0:00:01\n",
      "     --------------------------------------  38.3/38.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  38.7/38.8 MB 11.9 MB/s eta 0:00:01\n",
      "     --------------------------------------  38.8/38.8 MB 11.9 MB/s eta 0:00:01\n",
      "     --------------------------------------- 38.8/38.8 MB 11.3 MB/s eta 0:00:00\n",
      "Collecting opencv-contrib-python (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a7/9e/7110d2c5d543ab03b9581dbb1f8e2429863e44e0c9b4960b766f230c1279/opencv_contrib_python-4.10.0.84-cp37-abi3-win_amd64.whl (45.5 MB)\n",
      "     ---------------------------------------- 0.0/45.5 MB ? eta -:--:--\n",
      "     ---------------------------------------- 0.4/45.5 MB 13.9 MB/s eta 0:00:04\n",
      "      --------------------------------------- 0.6/45.5 MB 12.9 MB/s eta 0:00:04\n",
      "      --------------------------------------- 0.8/45.5 MB 7.4 MB/s eta 0:00:07\n",
      "     - -------------------------------------- 1.6/45.5 MB 11.6 MB/s eta 0:00:04\n",
      "     - -------------------------------------- 1.7/45.5 MB 10.8 MB/s eta 0:00:05\n",
      "     - -------------------------------------- 1.7/45.5 MB 9.0 MB/s eta 0:00:05\n",
      "     - -------------------------------------- 1.7/45.5 MB 9.0 MB/s eta 0:00:05\n",
      "     - -------------------------------------- 1.7/45.5 MB 6.1 MB/s eta 0:00:08\n",
      "     - -------------------------------------- 1.7/45.5 MB 6.1 MB/s eta 0:00:08\n",
      "     - -------------------------------------- 1.7/45.5 MB 6.1 MB/s eta 0:00:08\n",
      "     - -------------------------------------- 1.9/45.5 MB 4.7 MB/s eta 0:00:10\n",
      "     - -------------------------------------- 2.3/45.5 MB 5.2 MB/s eta 0:00:09\n",
      "     -- ------------------------------------- 2.4/45.5 MB 5.4 MB/s eta 0:00:09\n",
      "     -- ------------------------------------- 2.7/45.5 MB 5.4 MB/s eta 0:00:08\n",
      "     --- ------------------------------------ 3.5/45.5 MB 6.5 MB/s eta 0:00:07\n",
      "     --- ------------------------------------ 3.9/45.5 MB 6.7 MB/s eta 0:00:07\n",
      "     --- ------------------------------------ 4.3/45.5 MB 7.1 MB/s eta 0:00:06\n",
      "     ---- ----------------------------------- 4.7/45.5 MB 7.4 MB/s eta 0:00:06\n",
      "     ---- ----------------------------------- 5.1/45.5 MB 7.5 MB/s eta 0:00:06\n",
      "     ---- ----------------------------------- 5.4/45.5 MB 7.7 MB/s eta 0:00:06\n",
      "     ---- ----------------------------------- 5.5/45.5 MB 7.3 MB/s eta 0:00:06\n",
      "     ----- ---------------------------------- 6.4/45.5 MB 8.1 MB/s eta 0:00:05\n",
      "     ----- ---------------------------------- 6.8/45.5 MB 8.2 MB/s eta 0:00:05\n",
      "     ------ --------------------------------- 7.2/45.5 MB 8.3 MB/s eta 0:00:05\n",
      "     ------ --------------------------------- 7.6/45.5 MB 8.5 MB/s eta 0:00:05\n",
      "     ------- -------------------------------- 8.0/45.5 MB 8.6 MB/s eta 0:00:05\n",
      "     ------- -------------------------------- 8.5/45.5 MB 8.7 MB/s eta 0:00:05\n",
      "     ------- -------------------------------- 8.5/45.5 MB 8.8 MB/s eta 0:00:05\n",
      "     ------- -------------------------------- 8.9/45.5 MB 8.6 MB/s eta 0:00:05\n",
      "     -------- ------------------------------- 9.7/45.5 MB 9.0 MB/s eta 0:00:04\n",
      "     -------- ------------------------------- 10.1/45.5 MB 9.1 MB/s eta 0:00:04\n",
      "     --------- ------------------------------ 10.5/45.5 MB 9.2 MB/s eta 0:00:04\n",
      "     --------- ------------------------------ 10.9/45.5 MB 9.5 MB/s eta 0:00:04\n",
      "     --------- ------------------------------ 11.4/45.5 MB 9.4 MB/s eta 0:00:04\n",
      "     ---------- ----------------------------- 11.6/45.5 MB 9.1 MB/s eta 0:00:04\n",
      "     ---------- ----------------------------- 11.7/45.5 MB 8.7 MB/s eta 0:00:04\n",
      "     ---------- ---------------------------- 12.6/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 13.0/45.5 MB 11.9 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 13.4/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 13.9/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.3/45.5 MB 11.7 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.7/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.7/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------- ------------------------- 15.5/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------- ------------------------- 15.9/45.5 MB 11.9 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 16.4/45.5 MB 11.7 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 16.8/45.5 MB 11.7 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 17.2/45.5 MB 11.7 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 17.6/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 17.8/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 18.0/45.5 MB 11.1 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 18.9/45.5 MB 12.1 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 19.3/45.5 MB 11.9 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 19.7/45.5 MB 11.7 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.1/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.6/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.9/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.9/45.5 MB 10.9 MB/s eta 0:00:03\n",
      "     ------------------ -------------------- 21.8/45.5 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------------- ------------------- 22.2/45.5 MB 12.1 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 22.6/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 23.1/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 23.5/45.5 MB 11.7 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 23.9/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 24.0/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 24.3/45.5 MB 11.1 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 25.1/45.5 MB 11.9 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 25.5/45.5 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 26.0/45.5 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 26.4/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 26.8/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 27.1/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 27.2/45.5 MB 11.1 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 28.1/45.5 MB 12.1 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 28.5/45.5 MB 11.9 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 28.9/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 29.3/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 29.7/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 30.1/45.5 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 30.1/45.5 MB 11.7 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 31.0/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 31.4/45.5 MB 11.9 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 31.9/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 32.3/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 32.7/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 33.2/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 33.2/45.5 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 33.6/45.5 MB 11.1 MB/s eta 0:00:02\n",
      "     ----------------------------- --------- 34.4/45.5 MB 12.1 MB/s eta 0:00:01\n",
      "     ----------------------------- --------- 34.8/45.5 MB 11.9 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 35.3/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 35.7/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 36.1/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 36.3/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 36.5/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 37.3/45.5 MB 12.1 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 37.8/45.5 MB 11.9 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 38.2/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 38.6/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 39.0/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 39.3/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 39.4/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 40.2/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 40.7/45.5 MB 11.9 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 41.1/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 41.5/45.5 MB 11.7 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 41.9/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.3/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.4/45.5 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.8/45.5 MB 11.1 MB/s eta 0:00:01\n",
      "     --------------------------------------  44.8/45.5 MB 10.6 MB/s eta 0:00:01\n",
      "     --------------------------------------  45.5/45.5 MB 10.9 MB/s eta 0:00:01\n",
      "     --------------------------------------  45.5/45.5 MB 10.9 MB/s eta 0:00:01\n",
      "     --------------------------------------- 45.5/45.5 MB 10.4 MB/s eta 0:00:00\n",
      "Collecting cython (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/83/42/9537a513d7d83196ab5973d911056eb22a639e04162fd649cf74b4dac3f1/Cython-3.0.10-cp310-cp310-win_amd64.whl (2.8 MB)\n",
      "     ---------------------------------------- 0.0/2.8 MB ? eta -:--:--\n",
      "     ------ --------------------------------- 0.4/2.8 MB 13.9 MB/s eta 0:00:01\n",
      "     ------------ --------------------------- 0.9/2.8 MB 13.7 MB/s eta 0:00:01\n",
      "     ------------------ --------------------- 1.3/2.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------ --------------- 1.7/2.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ------------------------- -------------- 1.8/2.8 MB 12.7 MB/s eta 0:00:01\n",
      "     ------------------------------ --------- 2.1/2.8 MB 9.6 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 2.8/2.8 MB 11.1 MB/s eta 0:00:00\n",
      "Requirement already satisfied: Pillow in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from paddleocr) (10.4.0)\n",
      "Collecting pyyaml (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/24/97/9b59b43431f98d01806b288532da38099cc6f2fea0f3d712e21e269c0279/PyYAML-6.0.1-cp310-cp310-win_amd64.whl (145 kB)\n",
      "     ---------------------------------------- 0.0/145.3 kB ? eta -:--:--\n",
      "     -------------------------------------- 145.3/145.3 kB 8.4 MB/s eta 0:00:00\n",
      "Collecting python-docx (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3e/3d/330d9efbdb816d3f60bf2ad92f05e1708e4a1b9abe80461ac3444c83f749/python_docx-1.1.2-py3-none-any.whl (244 kB)\n",
      "     ---------------------------------------- 0.0/244.3 kB ? eta -:--:--\n",
      "     ------------------------------------- 244.3/244.3 kB 14.6 MB/s eta 0:00:00\n",
      "Collecting beautifulsoup4 (from paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b1/fe/e8c672695b37eecc5cbf43e1d0638d88d66ba3a44c4d321c796f4e59167f/beautifulsoup4-4.12.3-py3-none-any.whl (147 kB)\n",
      "Collecting fonttools>=4.24.0 (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/70/11/7b81b12a5614b5d237ab70c38bdc268de3eb3880ce7bb1269122e0a415ea/fonttools-4.53.1-cp310-cp310-win_amd64.whl (2.2 MB)\n",
      "     ---------------------------------------- 0.0/2.2 MB ? eta -:--:--\n",
      "     ------- -------------------------------- 0.4/2.2 MB 13.9 MB/s eta 0:00:01\n",
      "     ----------- ---------------------------- 0.6/2.2 MB 12.9 MB/s eta 0:00:01\n",
      "     --------------- ------------------------ 0.8/2.2 MB 7.4 MB/s eta 0:00:01\n",
      "     ----------------------------- ---------- 1.6/2.2 MB 11.6 MB/s eta 0:00:01\n",
      "     ------------------------------------- -- 2.1/2.2 MB 11.9 MB/s eta 0:00:01\n",
      "     ---------------------------------------  2.2/2.2 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------------  2.2/2.2 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------------  2.2/2.2 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------------  2.2/2.2 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------------  2.2/2.2 MB 11.7 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 2.2/2.2 MB 5.8 MB/s eta 0:00:00\n",
      "Collecting fire>=0.3.0 (from paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1b/1b/84c63f592ecdfbb3d77d22a8d93c9b92791e4fa35677ad71a7d6449100f8/fire-0.6.0.tar.gz (88 kB)\n",
      "     ---------------------------------------- 0.0/88.4 kB ? eta -:--:--\n",
      "     ---------------------------------------- 88.4/88.4 kB ? eta 0:00:00\n",
      "  Preparing metadata (setup.py): started\n",
      "  Preparing metadata (setup.py): finished with status 'done'\n",
      "Requirement already satisfied: six in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from fire>=0.3.0->paddleocr) (1.16.0)\n",
      "Collecting termcolor (from fire>=0.3.0->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/5f/8c716e47b3a50cbd7c146f45881e11d9414def768b7cd9c5e6650ec2a80a/termcolor-2.4.0-py3-none-any.whl (7.7 kB)\n",
      "Collecting soupsieve>1.2 (from beautifulsoup4->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4c/f3/038b302fdfbe3be7da016777069f26ceefe11a681055ea1f7817546508e3/soupsieve-2.5-py3-none-any.whl (36 kB)\n",
      "Collecting scipy (from imgaug->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/0c/82c1330c08f31d61142d38cb9a185e01c2403c990d10dab208032e62d0fa/scipy-1.14.0-cp310-cp310-win_amd64.whl (44.8 MB)\n",
      "     ---------------------------------------- 0.0/44.8 MB ? eta -:--:--\n",
      "     ---------------------------------------- 0.4/44.8 MB 13.9 MB/s eta 0:00:04\n",
      "      --------------------------------------- 0.8/44.8 MB 10.8 MB/s eta 0:00:05\n",
      "     - -------------------------------------- 1.3/44.8 MB 11.6 MB/s eta 0:00:04\n",
      "     - -------------------------------------- 1.7/44.8 MB 11.9 MB/s eta 0:00:04\n",
      "     - -------------------------------------- 2.1/44.8 MB 11.2 MB/s eta 0:00:04\n",
      "     - -------------------------------------- 2.2/44.8 MB 11.6 MB/s eta 0:00:04\n",
      "     -- ------------------------------------- 2.5/44.8 MB 10.0 MB/s eta 0:00:05\n",
      "     -- ------------------------------------- 3.3/44.8 MB 11.8 MB/s eta 0:00:04\n",
      "     --- ------------------------------------ 3.7/44.8 MB 11.3 MB/s eta 0:00:04\n",
      "     --- ------------------------------------ 4.2/44.8 MB 11.6 MB/s eta 0:00:04\n",
      "     ---- ----------------------------------- 4.6/44.8 MB 11.7 MB/s eta 0:00:04\n",
      "     ---- ----------------------------------- 5.0/44.8 MB 11.4 MB/s eta 0:00:04\n",
      "     ---- ----------------------------------- 5.3/44.8 MB 11.6 MB/s eta 0:00:04\n",
      "     ---- ----------------------------------- 5.4/44.8 MB 10.7 MB/s eta 0:00:04\n",
      "     ----- ---------------------------------- 6.2/44.8 MB 11.4 MB/s eta 0:00:04\n",
      "     ----- ---------------------------------- 6.6/44.8 MB 11.5 MB/s eta 0:00:04\n",
      "     ------ --------------------------------- 7.0/44.8 MB 11.5 MB/s eta 0:00:04\n",
      "     ------ --------------------------------- 7.0/44.8 MB 11.5 MB/s eta 0:00:04\n",
      "     ------ --------------------------------- 7.8/44.8 MB 11.4 MB/s eta 0:00:04\n",
      "     ------- -------------------------------- 8.1/44.8 MB 11.5 MB/s eta 0:00:04\n",
      "     ------- -------------------------------- 8.2/44.8 MB 10.9 MB/s eta 0:00:04\n",
      "     -------- ------------------------------- 9.0/44.8 MB 11.3 MB/s eta 0:00:04\n",
      "     -------- ------------------------------- 9.5/44.8 MB 11.4 MB/s eta 0:00:04\n",
      "     -------- ------------------------------- 9.9/44.8 MB 11.5 MB/s eta 0:00:04\n",
      "     -------- ------------------------------ 10.3/44.8 MB 11.3 MB/s eta 0:00:04\n",
      "     --------- ----------------------------- 10.7/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     --------- ----------------------------- 11.2/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     --------- ----------------------------- 11.3/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ---------- ---------------------------- 11.6/44.8 MB 10.9 MB/s eta 0:00:04\n",
      "     ---------- ---------------------------- 12.4/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 12.8/44.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 13.2/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------- --------------------------- 13.6/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.0/44.8 MB 11.3 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.3/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ------------ -------------------------- 14.4/44.8 MB 10.9 MB/s eta 0:00:03\n",
      "     ------------- ------------------------- 15.3/44.8 MB 11.3 MB/s eta 0:00:03\n",
      "     ------------- ------------------------- 15.7/44.8 MB 11.9 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 16.1/44.8 MB 11.7 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 16.6/44.8 MB 11.3 MB/s eta 0:00:03\n",
      "     -------------- ------------------------ 17.0/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 17.4/44.8 MB 12.1 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 17.4/44.8 MB 12.1 MB/s eta 0:00:03\n",
      "     --------------- ----------------------- 18.2/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 18.6/44.8 MB 12.1 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 19.1/44.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ---------------- ---------------------- 19.5/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 19.9/44.8 MB 11.5 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.3/44.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ----------------- --------------------- 20.5/44.8 MB 11.7 MB/s eta 0:00:03\n",
      "     ------------------ -------------------- 20.7/44.8 MB 11.1 MB/s eta 0:00:03\n",
      "     ------------------ -------------------- 21.6/44.8 MB 12.1 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 22.0/44.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 22.4/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------- ------------------- 22.8/44.8 MB 11.7 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 23.2/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 23.6/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------- ------------------ 23.6/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 24.5/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------- ----------------- 24.9/44.8 MB 11.9 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 25.3/44.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 25.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------- ---------------- 26.2/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 26.6/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 26.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ----------------------- --------------- 27.0/44.8 MB 11.1 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 27.8/44.8 MB 12.1 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 28.2/44.8 MB 11.9 MB/s eta 0:00:02\n",
      "     ------------------------ -------------- 28.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 29.1/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 29.5/44.8 MB 11.7 MB/s eta 0:00:02\n",
      "     ------------------------- ------------- 29.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 29.9/44.8 MB 11.1 MB/s eta 0:00:02\n",
      "     -------------------------- ------------ 30.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 31.2/44.8 MB 11.9 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 31.6/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     --------------------------- ----------- 32.0/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 32.5/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 32.7/44.8 MB 11.5 MB/s eta 0:00:02\n",
      "     ---------------------------- ---------- 32.9/44.8 MB 11.1 MB/s eta 0:00:02\n",
      "     ----------------------------- --------- 33.8/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------------------- --------- 34.2/44.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 34.6/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 35.0/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------ -------- 35.5/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 35.8/44.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 35.8/44.8 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------- ------- 36.7/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 37.1/44.8 MB 11.9 MB/s eta 0:00:01\n",
      "     -------------------------------- ------ 37.5/44.8 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 38.0/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 38.4/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 38.8/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------- ----- 38.9/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 39.4/44.8 MB 11.1 MB/s eta 0:00:01\n",
      "     ---------------------------------- ---- 40.0/44.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 40.5/44.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 40.9/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ----------------------------------- --- 41.3/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 41.7/44.8 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 41.9/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     ------------------------------------ -- 42.1/44.8 MB 11.1 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 43.0/44.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ------------------------------------- - 43.4/44.8 MB 11.9 MB/s eta 0:00:01\n",
      "     --------------------------------------  43.8/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  44.2/44.8 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------------  44.6/44.8 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------------------  44.8/44.8 MB 11.7 MB/s eta 0:00:01\n",
      "     --------------------------------------- 44.8/44.8 MB 10.9 MB/s eta 0:00:00\n",
      "Collecting matplotlib (from imgaug->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/be/f6/4ac7f10c1e8d51f42e320a0890ee7c8e45fb5b1178ed147f374a37900924/matplotlib-3.9.1-cp310-cp310-win_amd64.whl (8.0 MB)\n",
      "     ---------------------------------------- 0.0/8.0 MB ? eta -:--:--\n",
      "     -- ------------------------------------- 0.4/8.0 MB 13.4 MB/s eta 0:00:01\n",
      "     ---- ----------------------------------- 0.9/8.0 MB 13.8 MB/s eta 0:00:01\n",
      "     ------ --------------------------------- 1.3/8.0 MB 11.6 MB/s eta 0:00:01\n",
      "     -------- ------------------------------- 1.7/8.0 MB 12.1 MB/s eta 0:00:01\n",
      "     ---------- ----------------------------- 2.1/8.0 MB 12.4 MB/s eta 0:00:01\n",
      "     ---------- ----------------------------- 2.1/8.0 MB 12.4 MB/s eta 0:00:01\n",
      "     -------------- ------------------------- 2.9/8.0 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------- ----------------------- 3.4/8.0 MB 11.9 MB/s eta 0:00:01\n",
      "     ------------------ --------------------- 3.8/8.0 MB 12.0 MB/s eta 0:00:01\n",
      "     --------------------- ------------------ 4.2/8.0 MB 11.7 MB/s eta 0:00:01\n",
      "     ----------------------- ---------------- 4.6/8.0 MB 11.8 MB/s eta 0:00:01\n",
      "     ------------------------- -------------- 5.0/8.0 MB 11.9 MB/s eta 0:00:01\n",
      "     -------------------------- ------------- 5.3/8.0 MB 11.5 MB/s eta 0:00:01\n",
      "     --------------------------- ------------ 5.4/8.0 MB 10.9 MB/s eta 0:00:01\n",
      "     ------------------------------- -------- 6.3/8.0 MB 11.8 MB/s eta 0:00:01\n",
      "     --------------------------------- ------ 6.7/8.0 MB 11.6 MB/s eta 0:00:01\n",
      "     ----------------------------------- ---- 7.1/8.0 MB 11.7 MB/s eta 0:00:01\n",
      "     ------------------------------------- -- 7.5/8.0 MB 11.8 MB/s eta 0:00:01\n",
      "     ---------------------------------------  8.0/8.0 MB 11.5 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 8.0/8.0 MB 11.6 MB/s eta 0:00:00\n",
      "Collecting imageio (from imgaug->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3d/84/f1647217231f6cc46883e5d26e870cc3e1520d458ecd52d6df750810d53c/imageio-2.34.2-py3-none-any.whl (313 kB)\n",
      "     ---------------------------------------- 0.0/313.5 kB ? eta -:--:--\n",
      "     -------------------------------------- 313.5/313.5 kB 9.5 MB/s eta 0:00:00\n",
      "Collecting networkx>=2.8 (from scikit-image->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/38/e9/5f72929373e1a0e8d142a130f3f97e6ff920070f87f91c4e13e40e0fba5a/networkx-3.3-py3-none-any.whl (1.7 MB)\n",
      "     ---------------------------------------- 0.0/1.7 MB ? eta -:--:--\n",
      "     ---------- ----------------------------- 0.4/1.7 MB 9.2 MB/s eta 0:00:01\n",
      "     -------------- ------------------------- 0.6/1.7 MB 12.6 MB/s eta 0:00:01\n",
      "     ------------------- -------------------- 0.8/1.7 MB 7.6 MB/s eta 0:00:01\n",
      "     ---------------------------------------  1.7/1.7 MB 11.8 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 1.7/1.7 MB 10.8 MB/s eta 0:00:00\n",
      "Collecting tifffile>=2022.8.12 (from scikit-image->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d2/d7/ca95f347442e82700f591f3608e336596ee607daecbcad6a7ebd16ff5de4/tifffile-2024.7.2-py3-none-any.whl (225 kB)\n",
      "     ---------------------------------------- 0.0/225.9 kB ? eta -:--:--\n",
      "     ------------------------------------- 225.9/225.9 kB 13.5 MB/s eta 0:00:00\n",
      "Requirement already satisfied: packaging>=21 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from scikit-image->paddleocr) (24.1)\n",
      "Collecting lazy-loader>=0.4 (from scikit-image->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/83/60/d497a310bde3f01cb805196ac61b7ad6dc5dcf8dce66634dc34364b20b4f/lazy_loader-0.4-py3-none-any.whl (12 kB)\n",
      "Collecting lxml>=3.1.0 (from python-docx->paddleocr)\n",
      "  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5b/bc/51530ee31e3ce25634ed790e38a62ffaea6507befd73b51926e19ce794f9/lxml-5.2.2-cp310-cp310-win_amd64.whl (3.8 MB)\n",
      "     ---------------------------------------- 0.0/3.8 MB ? eta -:--:--\n",
      "     ---- ----------------------------------- 0.4/3.8 MB 13.9 MB/s eta 0:00:01\n",
      "     --------- ------------------------------ 0.9/3.8 MB 13.5 MB/s eta 0:00:01\n",
      "     ------------- -------------------------- 1.3/3.8 MB 13.4 MB/s eta 0:00:01\n",
      "     ----------------- ---------------------- 1.7/3.8 MB 12.0 MB/s eta 0:00:01\n",
      "     --------------------- ------------------ 2.1/3.8 MB 12.0 MB/s eta 0:00:01\n",
      "     --------------------- ------------------ 2.1/3.8 MB 12.0 MB/s eta 0:00:01\n",
      "     ------------------------------ --------- 2.9/3.8 MB 12.3 MB/s eta 0:00:01\n",
      "     ---------------------------------- ----- 3.3/3.8 MB 11.8 MB/s eta 0:00:01\n",
      "     ---------------------------------------  3.7/3.8 MB 11.9 MB/s eta 0:00:01\n",
      "     ---------------------------------------  3.8/3.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ---------------------------------------  3.8/3.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ---------------------------------------  3.8/3.8 MB 12.1 MB/s eta 0:00:01\n",
      "     ---------------------------------------- 3.8/3.8 MB 8.7 MB/s eta 0:00:00\n",
      "Requirement already satisfied: typing-extensions>=4.9.0 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from python-docx->paddleocr) (4.12.2)\n",
      "Requirement already satisfied: colorama in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from tqdm->paddleocr) (0.4.6)\n",
      "Collecting contourpy>=1.0.1 (from matplotlib->imgaug->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b6/b2/27c7a0d46c7dceb9083272eb314bef1ed43e5280a4197719656f866b496d/contourpy-1.2.1-cp310-cp310-win_amd64.whl (187 kB)\n",
      "Collecting cycler>=0.10 (from matplotlib->imgaug->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e7/05/c19819d5e3d95294a6f5947fb9b9629efb316b96de511b418c53d245aae6/cycler-0.12.1-py3-none-any.whl (8.3 kB)\n",
      "Collecting kiwisolver>=1.3.1 (from matplotlib->imgaug->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4a/a1/8a9c9be45c642fa12954855d8b3a02d9fd8551165a558835a19508fec2e6/kiwisolver-1.4.5-cp310-cp310-win_amd64.whl (56 kB)\n",
      "Collecting pyparsing>=2.3.1 (from matplotlib->imgaug->paddleocr)\n",
      "  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9d/ea/6d76df31432a0e6fdf81681a895f009a4bb47b3c39036db3e1b528191d52/pyparsing-3.1.2-py3-none-any.whl (103 kB)\n",
      "Requirement already satisfied: python-dateutil>=2.7 in g:\\anaconda3\\envs\\ollama\\lib\\site-packages (from matplotlib->imgaug->paddleocr) (2.9.0)\n",
      "Building wheels for collected packages: fire\n",
      "  Building wheel for fire (setup.py): started\n",
      "  Building wheel for fire (setup.py): finished with status 'done'\n",
      "  Created wheel for fire: filename=fire-0.6.0-py2.py3-none-any.whl size=117047 sha256=22e69b333ccc1c090a4020ceae6fbf453dd3a2964d62542fda76fa10fbb707ba\n",
      "  Stored in directory: c:\\users\\hyz\\appdata\\local\\pip\\cache\\wheels\\9b\\60\\2c\\5008fa6ebcacffde528fa94ebd28e3d901a38f1458869f375a\n",
      "Successfully built fire\n",
      "Installing collected packages: pyclipper, lmdb, tqdm, termcolor, soupsieve, rapidfuzz, pyyaml, pyparsing, numpy, networkx, lxml, lazy-loader, kiwisolver, fonttools, cython, cycler, tifffile, shapely, scipy, python-docx, opencv-python, opencv-contrib-python, imageio, fire, contourpy, beautifulsoup4, scikit-image, matplotlib, imgaug, paddleocr\n",
      "  Attempting uninstall: numpy\n",
      "    Found existing installation: numpy 2.0.0\n",
      "    Uninstalling numpy-2.0.0:\n",
      "      Successfully uninstalled numpy-2.0.0\n",
      "Successfully installed beautifulsoup4-4.12.3 contourpy-1.2.1 cycler-0.12.1 cython-3.0.10 fire-0.6.0 fonttools-4.53.1 imageio-2.34.2 imgaug-0.4.0 kiwisolver-1.4.5 lazy-loader-0.4 lmdb-1.5.1 lxml-5.2.2 matplotlib-3.9.1 networkx-3.3 numpy-1.26.4 opencv-contrib-python-4.10.0.84 opencv-python-4.10.0.84 paddleocr-2.8.0 pyclipper-1.3.0.post5 pyparsing-3.1.2 python-docx-1.1.2 pyyaml-6.0.1 rapidfuzz-3.9.4 scikit-image-0.24.0 scipy-1.14.0 shapely-2.0.5 soupsieve-2.5 termcolor-2.4.0 tifffile-2024.7.2 tqdm-4.66.4\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "## 安装paddleocr\n",
    "##使用ollama安装相关模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2024/07/31 15:36:31] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, use_npu=False, use_mlu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='C:\\\\Users\\\\HYZ/.paddleocr/whl\\\\det\\\\ch\\\\ch_PP-OCRv4_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='C:\\\\Users\\\\HYZ/.paddleocr/whl\\\\rec\\\\ch\\\\ch_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='g:\\\\anaconda3\\\\envs\\\\chatOCR\\\\lib\\\\site-packages\\\\paddleocr\\\\ppocr\\\\utils\\\\ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=True, cls_model_dir='C:\\\\Users\\\\HYZ/.paddleocr/whl\\\\cls\\\\ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, return_word_box=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', savefile=False, ocr_version='PP-OCRv4', structure_version='PP-StructureV2')\n"
     ]
    }
   ],
   "source": [
    "from paddleocr import PaddleOCR, draw_ocr\n",
    "from IPython import display\n",
    "# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换\n",
    "# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`\n",
    "ocr = PaddleOCR(use_angle_cls=True, lang=\"ch\")  # need to run only once to download and load model into memory\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2024/07/31 15:36:33] ppocr DEBUG: dt_boxes num : 88, elapsed : 0.5026240348815918\n",
      "[2024/07/31 15:36:33] ppocr DEBUG: cls num  : 88, elapsed : 0.20456933975219727\n",
      "[2024/07/31 15:36:35] ppocr DEBUG: rec_res num  : 88, elapsed : 1.8550949096679688\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[[[[[347.0, 403.0], [467.0, 403.0], [467.0, 462.0], [347.0, 462.0]],\n",
       "   ('附件：', 0.99541836977005)],\n",
       "  [[[436.0, 506.0], [1582.0, 513.0], [1582.0, 579.0], [436.0, 572.0]],\n",
       "   ('华南理工大学家庭经济困难本科生认定申请表', 0.9914814829826355)],\n",
       "  [[[344.0, 588.0], [1743.0, 588.0], [1743.0, 660.0], [344.0, 660.0]],\n",
       "   ('院系：生物理部转业：物理学年级：大三班级：33五学号：20101235', 0.8255273699760437)],\n",
       "  [[[395.0, 664.0], [496.0, 664.0], [496.0, 711.0], [395.0, 711.0]],\n",
       "   ('姓名', 0.9973807334899902)],\n",
       "  [[[550.0, 665.0], [680.0, 652.0], [688.0, 725.0], [558.0, 738.0]],\n",
       "   ('林造', 0.8331694602966309)],\n",
       "  [[[815.0, 667.0], [928.0, 667.0], [928.0, 714.0], [815.0, 714.0]],\n",
       "   ('性别', 0.9996743202209473)],\n",
       "  [[[973.0, 670.0], [1020.0, 670.0], [1020.0, 717.0], [973.0, 717.0]],\n",
       "   ('男', 0.910075306892395)],\n",
       "  [[[1118.0, 664.0], [1257.0, 664.0], [1257.0, 711.0], [1118.0, 711.0]],\n",
       "   ('出生年月', 0.9998351335525513)],\n",
       "  [[[1315.0, 675.0], [1512.0, 659.0], [1517.0, 725.0], [1320.0, 740.0]],\n",
       "   ('D001.5. 29', 0.6842592358589172)],\n",
       "  [[[1490.0, 667.0], [1626.0, 667.0], [1626.0, 714.0], [1490.0, 714.0]],\n",
       "   ('民族', 0.9996123909950256)],\n",
       "  [[[1683.0, 667.0], [1762.0, 667.0], [1762.0, 717.0], [1683.0, 717.0]],\n",
       "   ('汉', 0.9983117580413818)],\n",
       "  [[[388.0, 726.0], [499.0, 726.0], [499.0, 774.0], [388.0, 774.0]],\n",
       "   ('身份证', 0.999631941318512)],\n",
       "  [[[951.0, 726.0], [1026.0, 726.0], [1026.0, 774.0], [951.0, 774.0]],\n",
       "   ('户口', 0.9781391024589539)],\n",
       "  [[[1302.0, 742.0], [1557.0, 749.0], [1556.0, 806.0], [1300.0, 798.0]],\n",
       "   ('城镇农村', 0.9967422485351562)],\n",
       "  [[[650.0, 808.0], [1762.0, 805.0], [1762.0, 890.0], [651.0, 893.0]],\n",
       "   ('广西省（自治区）)南宁市青务县（市、区)五合镇（街道）五合村（居', 0.8261686563491821)],\n",
       "  [[[442.0, 830.0], [587.0, 830.0], [587.0, 877.0], [442.0, 877.0]],\n",
       "   ('户籍地址', 0.9994264245033264)],\n",
       "  [[[407.0, 896.0], [622.0, 896.0], [622.0, 950.0], [407.0, 950.0]],\n",
       "   ('家长手机号码', 0.9996353983879089)],\n",
       "  [[[664.0, 893.0], [929.0, 900.0], [927.0, 957.0], [663.0, 949.0]],\n",
       "   ('13700137002', 0.9590243697166443)],\n",
       "  [[[982.0, 893.0], [1225.0, 893.0], [1225.0, 947.0], [982.0, 947.0]],\n",
       "   ('家庭人均年收入', 0.9998812675476074)],\n",
       "  [[[1573.0, 899.0], [1652.0, 899.0], [1652.0, 950.0], [1573.0, 950.0]],\n",
       "   ('（元）', 0.9795417785644531)],\n",
       "  [[[426.0, 962.0], [606.0, 962.0], [606.0, 1019.0], [426.0, 1019.0]],\n",
       "   ('家庭人口数', 0.9995239973068237)],\n",
       "  [[[963.0, 965.0], [1238.0, 965.0], [1238.0, 1019.0], [963.0, 1019.0]],\n",
       "   ('家庭成员在学人数', 0.9997978806495667)],\n",
       "  [[[272.0, 994.0], [325.0, 994.0], [325.0, 1054.0], [272.0, 1054.0]],\n",
       "   ('家', 0.999962568283081)],\n",
       "  [[[442.0, 1038.0], [587.0, 1038.0], [587.0, 1085.0], [442.0, 1085.0]],\n",
       "   ('赠养人数', 0.981840193271637)],\n",
       "  [[[959.0, 1035.0], [1240.0, 1028.0], [1241.0, 1081.0], [961.0, 1089.0]],\n",
       "   ('家庭成员失业人数', 0.9995684623718262)],\n",
       "  [[[278.0, 1054.0], [322.0, 1054.0], [322.0, 1104.0], [278.0, 1104.0]],\n",
       "   ('庭', 0.9976884126663208)],\n",
       "  [[[272.0, 1104.0], [325.0, 1104.0], [325.0, 1160.0], [272.0, 1160.0]],\n",
       "   ('情', 0.9979397654533386)],\n",
       "  [[[379.0, 1107.0], [1775.0, 1107.0], [1775.0, 1160.0], [379.0, 1160.0]],\n",
       "   ('1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低', 0.9983638525009155)],\n",
       "  [[[275.0, 1160.0], [319.0, 1160.0], [319.0, 1208.0], [275.0, 1208.0]],\n",
       "   ('况', 0.999954342842102)],\n",
       "  [[[379.0, 1160.0], [1772.0, 1160.0], [1772.0, 1214.0], [379.0, 1214.0]],\n",
       "   ('生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享', 0.9967440962791443)],\n",
       "  [[[379.0, 1214.0], [1775.0, 1214.0], [1775.0, 1267.0], [379.0, 1267.0]],\n",
       "   ('受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职', 0.9679998755455017)],\n",
       "  [[[376.0, 1267.0], [1102.0, 1267.0], [1102.0, 1321.0], [376.0, 1321.0]],\n",
       "   ('工子女12.家庭经济困难残疾学生13.残疾人子女', 0.9994675517082214)],\n",
       "  [[[379.0, 1327.0], [903.0, 1327.0], [903.0, 1371.0], [379.0, 1371.0]],\n",
       "   ('如符合上述类型，请填写相应数字：', 0.9992081522941589)],\n",
       "  [[[676.0, 1390.0], [789.0, 1390.0], [789.0, 1447.0], [676.0, 1447.0]],\n",
       "   ('与学生', 0.9998922348022461)],\n",
       "  [[[1475.0, 1383.0], [1583.0, 1391.0], [1579.0, 1448.0], [1470.0, 1439.0]],\n",
       "   ('年收入', 0.9999616742134094)],\n",
       "  [[[834.0, 1393.0], [1033.0, 1393.0], [1033.0, 1447.0], [834.0, 1447.0]],\n",
       "   ('工作（学习）', 0.891996443271637)],\n",
       "  [[[556.0, 1415.0], [632.0, 1415.0], [632.0, 1469.0], [556.0, 1469.0]],\n",
       "   ('年龄', 0.9999966025352478)],\n",
       "  [[[1291.0, 1408.0], [1438.0, 1416.0], [1435.0, 1473.0], [1287.0, 1465.0]],\n",
       "   ('文化程度', 0.9998476505279541)],\n",
       "  [[[404.0, 1418.0], [483.0, 1418.0], [483.0, 1472.0], [404.0, 1472.0]],\n",
       "   ('姓名', 0.9997830390930176)],\n",
       "  [[[1613.0, 1411.0], [1766.0, 1419.0], [1763.0, 1476.0], [1610.0, 1468.0]],\n",
       "   ('健康状况', 0.9999206066131592)],\n",
       "  [[[1102.0, 1421.0], [1247.0, 1421.0], [1247.0, 1469.0], [1102.0, 1469.0]],\n",
       "   ('从业情况', 0.9994960427284241)],\n",
       "  [[[692.0, 1440.0], [777.0, 1440.0], [777.0, 1497.0], [692.0, 1497.0]],\n",
       "   ('关系', 0.9999296069145203)],\n",
       "  [[[903.0, 1443.0], [982.0, 1443.0], [982.0, 1497.0], [903.0, 1497.0]],\n",
       "   ('单位', 0.999997615814209)],\n",
       "  [[[1490.0, 1440.0], [1576.0, 1440.0], [1576.0, 1497.0], [1490.0, 1497.0]],\n",
       "   ('（元）', 0.9944948554039001)],\n",
       "  [[[272.0, 1456.0], [325.0, 1456.0], [325.0, 1761.0], [272.0, 1761.0]],\n",
       "   ('主要家庭成员情况', 0.998633623123169)],\n",
       "  [[[369.0, 1503.0], [489.0, 1503.0], [489.0, 1579.0], [369.0, 1579.0]],\n",
       "   ('林安', 0.9829299449920654)],\n",
       "  [[[695.0, 1500.0], [796.0, 1500.0], [796.0, 1576.0], [695.0, 1576.0]],\n",
       "   ('父条', 0.6837480068206787)],\n",
       "  [[[878.0, 1506.0], [988.0, 1506.0], [988.0, 1579.0], [878.0, 1579.0]],\n",
       "   ('农民', 0.984403669834137)],\n",
       "  [[[1112.0, 1506.0], [1254.0, 1506.0], [1254.0, 1576.0], [1112.0, 1576.0]],\n",
       "   ('了季工', 0.5566554069519043)],\n",
       "  [[[1307.0, 1500.0], [1418.0, 1500.0], [1418.0, 1576.0], [1307.0, 1576.0]],\n",
       "   ('小学', 0.9444129467010498)],\n",
       "  [[[1467.0, 1503.0], [1584.0, 1514.0], [1577.0, 1577.0], [1460.0, 1566.0]],\n",
       "   ('7000', 0.8910413980484009)],\n",
       "  [[[564.0, 1516.0], [633.0, 1508.0], [639.0, 1565.0], [570.0, 1572.0]],\n",
       "   ('49', 0.9973170161247253)],\n",
       "  [[[1626.0, 1510.0], [1734.0, 1510.0], [1734.0, 1572.0], [1626.0, 1572.0]],\n",
       "   ('二般', 0.6773449182510376)],\n",
       "  [[[379.0, 1576.0], [502.0, 1576.0], [502.0, 1648.0], [379.0, 1648.0]],\n",
       "   ('张宁', 0.9817266464233398)],\n",
       "  [[[688.0, 1576.0], [796.0, 1576.0], [796.0, 1651.0], [688.0, 1651.0]],\n",
       "   ('母年', 0.8317743539810181)],\n",
       "  [[[1079.0, 1568.0], [1267.0, 1576.0], [1264.0, 1646.0], [1076.0, 1638.0]],\n",
       "   ('家庭主妇', 0.9449476003646851)],\n",
       "  [[[913.0, 1579.0], [973.0, 1579.0], [973.0, 1638.0], [913.0, 1638.0]],\n",
       "   ('无', 0.5750243663787842)],\n",
       "  [[[1307.0, 1572.0], [1415.0, 1572.0], [1415.0, 1648.0], [1307.0, 1648.0]],\n",
       "   ('中', 0.9938055276870728)],\n",
       "  [[[1636.0, 1572.0], [1759.0, 1572.0], [1759.0, 1645.0], [1636.0, 1645.0]],\n",
       "   ('良好', 0.9938517808914185)],\n",
       "  [[[575.0, 1591.0], [638.0, 1591.0], [638.0, 1642.0], [575.0, 1642.0]],\n",
       "   ('47', 0.9665005207061768)],\n",
       "  [[[1522.0, 1585.0], [1563.0, 1585.0], [1563.0, 1632.0], [1522.0, 1632.0]],\n",
       "   ('D', 0.8154764175415039)],\n",
       "  [[[382.0, 1859.0], [739.0, 1859.0], [739.0, 1912.0], [382.0, 1912.0]],\n",
       "   ('家庭遭受自然灾害情况：', 0.997475802898407)],\n",
       "  [[[821.0, 1855.0], [925.0, 1855.0], [925.0, 1909.0], [821.0, 1909.0]],\n",
       "   ('台风', 0.9862732887268066)],\n",
       "  [[[1048.0, 1859.0], [1427.0, 1859.0], [1427.0, 1912.0], [1048.0, 1912.0]],\n",
       "   ('家庭遭受突发意外事件：', 0.9956655502319336)],\n",
       "  [[[259.0, 1890.0], [338.0, 1890.0], [338.0, 1940.0], [259.0, 1940.0]],\n",
       "   ('影响', 0.9999884366989136)],\n",
       "  [[[259.0, 1934.0], [338.0, 1934.0], [338.0, 1988.0], [259.0, 1988.0]],\n",
       "   ('家庭', 0.9998058080673218)],\n",
       "  [[[372.0, 1928.0], [1117.0, 1911.0], [1118.0, 1984.0], [374.0, 2001.0]],\n",
       "   ('家庭成员因残疾、年迈而劳动能力弱情况：之', 0.9743223190307617)],\n",
       "  [[[259.0, 1984.0], [338.0, 1984.0], [338.0, 2035.0], [259.0, 2035.0]],\n",
       "   ('经济', 0.9996976852416992)],\n",
       "  [[[723.0, 1991.0], [932.0, 1991.0], [932.0, 2057.0], [723.0, 2057.0]],\n",
       "   ('母亲失业', 0.8576893210411072)],\n",
       "  [[[988.0, 1994.0], [1597.0, 1987.0], [1598.0, 2050.0], [989.0, 2057.0]],\n",
       "   ('。家庭欠债情况：资20D0元', 0.8555508852005005)],\n",
       "  [[[388.0, 2010.0], [669.0, 2010.0], [669.0, 2054.0], [388.0, 2054.0]],\n",
       "   ('家庭成员失业情况：', 0.9987879991531372)],\n",
       "  [[[259.0, 2032.0], [338.0, 2032.0], [338.0, 2079.0], [259.0, 2079.0]],\n",
       "   ('状况', 0.9999595880508423)],\n",
       "  [[[259.0, 2076.0], [338.0, 2076.0], [338.0, 2126.0], [259.0, 2126.0]],\n",
       "   ('有关', 0.9998517036437988)],\n",
       "  [[[382.0, 2076.0], [575.0, 2076.0], [575.0, 2129.0], [382.0, 2129.0]],\n",
       "   ('其他情况：', 0.9998567700386047)],\n",
       "  [[[594.0, 2079.0], [647.0, 2079.0], [647.0, 2123.0], [594.0, 2123.0]],\n",
       "   ('无', 0.7921909093856812)],\n",
       "  [[[259.0, 2123.0], [338.0, 2123.0], [338.0, 2173.0], [259.0, 2173.0]],\n",
       "   ('信息', 0.9998416900634766)],\n",
       "  [[[379.0, 2233.0], [524.0, 2233.0], [524.0, 2277.0], [379.0, 2277.0]],\n",
       "   ('承诺内容：', 0.9986754655838013)],\n",
       "  [[[275.0, 2362.0], [322.0, 2362.0], [322.0, 2513.0], [275.0, 2513.0]],\n",
       "   ('个人承诺', 0.9962604641914368)],\n",
       "  [[[1096.0, 2390.0], [1393.0, 2390.0], [1393.0, 2434.0], [1096.0, 2434.0]],\n",
       "   ('街道办或村委会联系', 0.9979970455169678)],\n",
       "  [[[1429.0, 2401.0], [1759.0, 2379.0], [1764.0, 2455.0], [1434.0, 2476.0]],\n",
       "   ('771-8711243', 0.9769994616508484)],\n",
       "  [[[1139.0, 2441.0], [1334.0, 2433.0], [1336.0, 2490.0], [1141.0, 2498.0]],\n",
       "   ('电话 (必填）', 0.8491547703742981)],\n",
       "  [[[385.0, 2541.0], [619.0, 2541.0], [619.0, 2594.0], [385.0, 2594.0]],\n",
       "   ('学生本人签名：', 0.9994810819625854)]]]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython import display\n",
    "img_path = 'image/a83.jpg'\n",
    "display.Image(filename=img_path, width=640)\n",
    "result = ocr.ocr(img_path, cls=True)\n",
    "\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[347.0, 403.0], [467.0, 403.0], [467.0, 462.0], [347.0, 462.0]], ('附件：', 0.99541836977005)]\n",
      "[[[436.0, 506.0], [1582.0, 513.0], [1582.0, 579.0], [436.0, 572.0]], ('华南理工大学家庭经济困难本科生认定申请表', 0.9914814829826355)]\n",
      "[[[344.0, 588.0], [1743.0, 588.0], [1743.0, 660.0], [344.0, 660.0]], ('院系：生物理部转业：物理学年级：大三班级：33五学号：20101235', 0.8255273699760437)]\n",
      "[[[395.0, 664.0], [496.0, 664.0], [496.0, 711.0], [395.0, 711.0]], ('姓名', 0.9973807334899902)]\n",
      "[[[550.0, 665.0], [680.0, 652.0], [688.0, 725.0], [558.0, 738.0]], ('林造', 0.8331694602966309)]\n",
      "[[[815.0, 667.0], [928.0, 667.0], [928.0, 714.0], [815.0, 714.0]], ('性别', 0.9996743202209473)]\n",
      "[[[973.0, 670.0], [1020.0, 670.0], [1020.0, 717.0], [973.0, 717.0]], ('男', 0.910075306892395)]\n",
      "[[[1118.0, 664.0], [1257.0, 664.0], [1257.0, 711.0], [1118.0, 711.0]], ('出生年月', 0.9998351335525513)]\n",
      "[[[1315.0, 675.0], [1512.0, 659.0], [1517.0, 725.0], [1320.0, 740.0]], ('D001.5. 29', 0.6842592358589172)]\n",
      "[[[1490.0, 667.0], [1626.0, 667.0], [1626.0, 714.0], [1490.0, 714.0]], ('民族', 0.9996123909950256)]\n",
      "[[[1683.0, 667.0], [1762.0, 667.0], [1762.0, 717.0], [1683.0, 717.0]], ('汉', 0.9983117580413818)]\n",
      "[[[388.0, 726.0], [499.0, 726.0], [499.0, 774.0], [388.0, 774.0]], ('身份证', 0.999631941318512)]\n",
      "[[[951.0, 726.0], [1026.0, 726.0], [1026.0, 774.0], [951.0, 774.0]], ('户口', 0.9781391024589539)]\n",
      "[[[1302.0, 742.0], [1557.0, 749.0], [1556.0, 806.0], [1300.0, 798.0]], ('城镇农村', 0.9967422485351562)]\n",
      "[[[650.0, 808.0], [1762.0, 805.0], [1762.0, 890.0], [651.0, 893.0]], ('广西省（自治区）)南宁市青务县（市、区)五合镇（街道）五合村（居', 0.8261686563491821)]\n",
      "[[[442.0, 830.0], [587.0, 830.0], [587.0, 877.0], [442.0, 877.0]], ('户籍地址', 0.9994264245033264)]\n",
      "[[[407.0, 896.0], [622.0, 896.0], [622.0, 950.0], [407.0, 950.0]], ('家长手机号码', 0.9996353983879089)]\n",
      "[[[664.0, 893.0], [929.0, 900.0], [927.0, 957.0], [663.0, 949.0]], ('13700137002', 0.9590243697166443)]\n",
      "[[[982.0, 893.0], [1225.0, 893.0], [1225.0, 947.0], [982.0, 947.0]], ('家庭人均年收入', 0.9998812675476074)]\n",
      "[[[1573.0, 899.0], [1652.0, 899.0], [1652.0, 950.0], [1573.0, 950.0]], ('（元）', 0.9795417785644531)]\n",
      "[[[426.0, 962.0], [606.0, 962.0], [606.0, 1019.0], [426.0, 1019.0]], ('家庭人口数', 0.9995239973068237)]\n",
      "[[[963.0, 965.0], [1238.0, 965.0], [1238.0, 1019.0], [963.0, 1019.0]], ('家庭成员在学人数', 0.9997978806495667)]\n",
      "[[[272.0, 994.0], [325.0, 994.0], [325.0, 1054.0], [272.0, 1054.0]], ('家', 0.999962568283081)]\n",
      "[[[442.0, 1038.0], [587.0, 1038.0], [587.0, 1085.0], [442.0, 1085.0]], ('赠养人数', 0.981840193271637)]\n",
      "[[[959.0, 1035.0], [1240.0, 1028.0], [1241.0, 1081.0], [961.0, 1089.0]], ('家庭成员失业人数', 0.9995684623718262)]\n",
      "[[[278.0, 1054.0], [322.0, 1054.0], [322.0, 1104.0], [278.0, 1104.0]], ('庭', 0.9976884126663208)]\n",
      "[[[272.0, 1104.0], [325.0, 1104.0], [325.0, 1160.0], [272.0, 1160.0]], ('情', 0.9979397654533386)]\n",
      "[[[379.0, 1107.0], [1775.0, 1107.0], [1775.0, 1160.0], [379.0, 1160.0]], ('1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低', 0.9983638525009155)]\n",
      "[[[275.0, 1160.0], [319.0, 1160.0], [319.0, 1208.0], [275.0, 1208.0]], ('况', 0.999954342842102)]\n",
      "[[[379.0, 1160.0], [1772.0, 1160.0], [1772.0, 1214.0], [379.0, 1214.0]], ('生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享', 0.9967440962791443)]\n",
      "[[[379.0, 1214.0], [1775.0, 1214.0], [1775.0, 1267.0], [379.0, 1267.0]], ('受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职', 0.9679998755455017)]\n",
      "[[[376.0, 1267.0], [1102.0, 1267.0], [1102.0, 1321.0], [376.0, 1321.0]], ('工子女12.家庭经济困难残疾学生13.残疾人子女', 0.9994675517082214)]\n",
      "[[[379.0, 1327.0], [903.0, 1327.0], [903.0, 1371.0], [379.0, 1371.0]], ('如符合上述类型，请填写相应数字：', 0.9992081522941589)]\n",
      "[[[676.0, 1390.0], [789.0, 1390.0], [789.0, 1447.0], [676.0, 1447.0]], ('与学生', 0.9998922348022461)]\n",
      "[[[1475.0, 1383.0], [1583.0, 1391.0], [1579.0, 1448.0], [1470.0, 1439.0]], ('年收入', 0.9999616742134094)]\n",
      "[[[834.0, 1393.0], [1033.0, 1393.0], [1033.0, 1447.0], [834.0, 1447.0]], ('工作（学习）', 0.891996443271637)]\n",
      "[[[556.0, 1415.0], [632.0, 1415.0], [632.0, 1469.0], [556.0, 1469.0]], ('年龄', 0.9999966025352478)]\n",
      "[[[1291.0, 1408.0], [1438.0, 1416.0], [1435.0, 1473.0], [1287.0, 1465.0]], ('文化程度', 0.9998476505279541)]\n",
      "[[[404.0, 1418.0], [483.0, 1418.0], [483.0, 1472.0], [404.0, 1472.0]], ('姓名', 0.9997830390930176)]\n",
      "[[[1613.0, 1411.0], [1766.0, 1419.0], [1763.0, 1476.0], [1610.0, 1468.0]], ('健康状况', 0.9999206066131592)]\n",
      "[[[1102.0, 1421.0], [1247.0, 1421.0], [1247.0, 1469.0], [1102.0, 1469.0]], ('从业情况', 0.9994960427284241)]\n",
      "[[[692.0, 1440.0], [777.0, 1440.0], [777.0, 1497.0], [692.0, 1497.0]], ('关系', 0.9999296069145203)]\n",
      "[[[903.0, 1443.0], [982.0, 1443.0], [982.0, 1497.0], [903.0, 1497.0]], ('单位', 0.999997615814209)]\n",
      "[[[1490.0, 1440.0], [1576.0, 1440.0], [1576.0, 1497.0], [1490.0, 1497.0]], ('（元）', 0.9944948554039001)]\n",
      "[[[272.0, 1456.0], [325.0, 1456.0], [325.0, 1761.0], [272.0, 1761.0]], ('主要家庭成员情况', 0.998633623123169)]\n",
      "[[[369.0, 1503.0], [489.0, 1503.0], [489.0, 1579.0], [369.0, 1579.0]], ('林安', 0.9829299449920654)]\n",
      "[[[695.0, 1500.0], [796.0, 1500.0], [796.0, 1576.0], [695.0, 1576.0]], ('父条', 0.6837480068206787)]\n",
      "[[[878.0, 1506.0], [988.0, 1506.0], [988.0, 1579.0], [878.0, 1579.0]], ('农民', 0.984403669834137)]\n",
      "[[[1112.0, 1506.0], [1254.0, 1506.0], [1254.0, 1576.0], [1112.0, 1576.0]], ('了季工', 0.5566554069519043)]\n",
      "[[[1307.0, 1500.0], [1418.0, 1500.0], [1418.0, 1576.0], [1307.0, 1576.0]], ('小学', 0.9444129467010498)]\n",
      "[[[1467.0, 1503.0], [1584.0, 1514.0], [1577.0, 1577.0], [1460.0, 1566.0]], ('7000', 0.8910413980484009)]\n",
      "[[[564.0, 1516.0], [633.0, 1508.0], [639.0, 1565.0], [570.0, 1572.0]], ('49', 0.9973170161247253)]\n",
      "[[[1626.0, 1510.0], [1734.0, 1510.0], [1734.0, 1572.0], [1626.0, 1572.0]], ('二般', 0.6773449182510376)]\n",
      "[[[379.0, 1576.0], [502.0, 1576.0], [502.0, 1648.0], [379.0, 1648.0]], ('张宁', 0.9817266464233398)]\n",
      "[[[688.0, 1576.0], [796.0, 1576.0], [796.0, 1651.0], [688.0, 1651.0]], ('母年', 0.8317743539810181)]\n",
      "[[[1079.0, 1568.0], [1267.0, 1576.0], [1264.0, 1646.0], [1076.0, 1638.0]], ('家庭主妇', 0.9449476003646851)]\n",
      "[[[913.0, 1579.0], [973.0, 1579.0], [973.0, 1638.0], [913.0, 1638.0]], ('无', 0.5750243663787842)]\n",
      "[[[1307.0, 1572.0], [1415.0, 1572.0], [1415.0, 1648.0], [1307.0, 1648.0]], ('中', 0.9938055276870728)]\n",
      "[[[1636.0, 1572.0], [1759.0, 1572.0], [1759.0, 1645.0], [1636.0, 1645.0]], ('良好', 0.9938517808914185)]\n",
      "[[[575.0, 1591.0], [638.0, 1591.0], [638.0, 1642.0], [575.0, 1642.0]], ('47', 0.9665005207061768)]\n",
      "[[[1522.0, 1585.0], [1563.0, 1585.0], [1563.0, 1632.0], [1522.0, 1632.0]], ('D', 0.8154764175415039)]\n",
      "[[[382.0, 1859.0], [739.0, 1859.0], [739.0, 1912.0], [382.0, 1912.0]], ('家庭遭受自然灾害情况：', 0.997475802898407)]\n",
      "[[[821.0, 1855.0], [925.0, 1855.0], [925.0, 1909.0], [821.0, 1909.0]], ('台风', 0.9862732887268066)]\n",
      "[[[1048.0, 1859.0], [1427.0, 1859.0], [1427.0, 1912.0], [1048.0, 1912.0]], ('家庭遭受突发意外事件：', 0.9956655502319336)]\n",
      "[[[259.0, 1890.0], [338.0, 1890.0], [338.0, 1940.0], [259.0, 1940.0]], ('影响', 0.9999884366989136)]\n",
      "[[[259.0, 1934.0], [338.0, 1934.0], [338.0, 1988.0], [259.0, 1988.0]], ('家庭', 0.9998058080673218)]\n",
      "[[[372.0, 1928.0], [1117.0, 1911.0], [1118.0, 1984.0], [374.0, 2001.0]], ('家庭成员因残疾、年迈而劳动能力弱情况：之', 0.9743223190307617)]\n",
      "[[[259.0, 1984.0], [338.0, 1984.0], [338.0, 2035.0], [259.0, 2035.0]], ('经济', 0.9996976852416992)]\n",
      "[[[723.0, 1991.0], [932.0, 1991.0], [932.0, 2057.0], [723.0, 2057.0]], ('母亲失业', 0.8576893210411072)]\n",
      "[[[988.0, 1994.0], [1597.0, 1987.0], [1598.0, 2050.0], [989.0, 2057.0]], ('。家庭欠债情况：资20D0元', 0.8555508852005005)]\n",
      "[[[388.0, 2010.0], [669.0, 2010.0], [669.0, 2054.0], [388.0, 2054.0]], ('家庭成员失业情况：', 0.9987879991531372)]\n",
      "[[[259.0, 2032.0], [338.0, 2032.0], [338.0, 2079.0], [259.0, 2079.0]], ('状况', 0.9999595880508423)]\n",
      "[[[259.0, 2076.0], [338.0, 2076.0], [338.0, 2126.0], [259.0, 2126.0]], ('有关', 0.9998517036437988)]\n",
      "[[[382.0, 2076.0], [575.0, 2076.0], [575.0, 2129.0], [382.0, 2129.0]], ('其他情况：', 0.9998567700386047)]\n",
      "[[[594.0, 2079.0], [647.0, 2079.0], [647.0, 2123.0], [594.0, 2123.0]], ('无', 0.7921909093856812)]\n",
      "[[[259.0, 2123.0], [338.0, 2123.0], [338.0, 2173.0], [259.0, 2173.0]], ('信息', 0.9998416900634766)]\n",
      "[[[379.0, 2233.0], [524.0, 2233.0], [524.0, 2277.0], [379.0, 2277.0]], ('承诺内容：', 0.9986754655838013)]\n",
      "[[[275.0, 2362.0], [322.0, 2362.0], [322.0, 2513.0], [275.0, 2513.0]], ('个人承诺', 0.9962604641914368)]\n",
      "[[[1096.0, 2390.0], [1393.0, 2390.0], [1393.0, 2434.0], [1096.0, 2434.0]], ('街道办或村委会联系', 0.9979970455169678)]\n",
      "[[[1429.0, 2401.0], [1759.0, 2379.0], [1764.0, 2455.0], [1434.0, 2476.0]], ('771-8711243', 0.9769994616508484)]\n",
      "[[[1139.0, 2441.0], [1334.0, 2433.0], [1336.0, 2490.0], [1141.0, 2498.0]], ('电话 (必填）', 0.8491547703742981)]\n",
      "[[[385.0, 2541.0], [619.0, 2541.0], [619.0, 2594.0], [385.0, 2594.0]], ('学生本人签名：', 0.9994810819625854)]\n"
     ]
    }
   ],
   "source": [
    "for idx in range(len(result)):\n",
    "    res = result[idx]\n",
    "    for line in res:\n",
    "        print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2024/07/31 15:36:36] ppocr DEBUG: dt_boxes num : 88, elapsed : 0.13702869415283203\n",
      "[2024/07/31 15:36:36] ppocr DEBUG: cls num  : 88, elapsed : 0.12602925300598145\n",
      "[2024/07/31 15:36:38] ppocr DEBUG: rec_res num  : 88, elapsed : 1.4594545364379883\n",
      "附件：\n",
      "华南理工大学家庭经济困难本科生认定申请表\n",
      "院系：生物理部转业：物理学年级：大三班级：33五学号：20101235\n",
      "姓名\n",
      "林造\n",
      "性别\n",
      "男\n",
      "出生年月\n",
      "D001.5. 29\n",
      "民族\n",
      "汉\n",
      "身份证\n",
      "户口\n",
      "城镇农村\n",
      "广西省（自治区）)南宁市青务县（市、区)五合镇（街道）五合村（居\n",
      "户籍地址\n",
      "家长手机号码\n",
      "13700137002\n",
      "家庭人均年收入\n",
      "（元）\n",
      "家庭人口数\n",
      "家庭成员在学人数\n",
      "家\n",
      "赠养人数\n",
      "家庭成员失业人数\n",
      "庭\n",
      "情\n",
      "1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低\n",
      "况\n",
      "生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享\n",
      "受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职\n",
      "工子女12.家庭经济困难残疾学生13.残疾人子女\n",
      "如符合上述类型，请填写相应数字：\n",
      "与学生\n",
      "年收入\n",
      "工作（学习）\n",
      "年龄\n",
      "文化程度\n",
      "姓名\n",
      "健康状况\n",
      "从业情况\n",
      "关系\n",
      "单位\n",
      "（元）\n",
      "主要家庭成员情况\n",
      "林安\n",
      "父条\n",
      "农民\n",
      "了季工\n",
      "小学\n",
      "7000\n",
      "49\n",
      "二般\n",
      "张宁\n",
      "母年\n",
      "家庭主妇\n",
      "无\n",
      "中\n",
      "良好\n",
      "47\n",
      "D\n",
      "家庭遭受自然灾害情况：\n",
      "台风\n",
      "家庭遭受突发意外事件：\n",
      "影响\n",
      "家庭\n",
      "家庭成员因残疾、年迈而劳动能力弱情况：之\n",
      "经济\n",
      "母亲失业\n",
      "。家庭欠债情况：资20D0元\n",
      "家庭成员失业情况：\n",
      "状况\n",
      "有关\n",
      "其他情况：\n",
      "无\n",
      "信息\n",
      "承诺内容：\n",
      "个人承诺\n",
      "街道办或村委会联系\n",
      "771-8711243\n",
      "电话 (必填）\n",
      "学生本人签名：\n",
      "[2024/07/31 15:36:38] ppocr DEBUG: dt_boxes num : 96, elapsed : 0.14043784141540527\n",
      "[2024/07/31 15:36:38] ppocr DEBUG: cls num  : 96, elapsed : 0.13703107833862305\n",
      "[2024/07/31 15:36:40] ppocr DEBUG: rec_res num  : 96, elapsed : 2.1438190937042236\n",
      "附件：\n",
      "华南理工大学家庭经济困难本科生认定申请表\n",
      "院系：教学转业：小教育年级：大四班级：1学号：201801567\n",
      "黄丽\n",
      "性别女\n",
      "如名\n",
      "出生年月\n",
      "民族\n",
      "2bD02121\n",
      "汉\n",
      "身份证\n",
      "户口\n",
      "城镇农村\n",
      "360101/200002/22345\n",
      "号码\n",
      "性质\n",
      "户籍地址\n",
      "家长手机号码\n",
      "13500135002\n",
      "家庭人均年收入\n",
      "14000\n",
      "（元）\n",
      "家庭人口数\n",
      "家庭成员在学人数\n",
      "4\n",
      "家\n",
      "赠养人数\n",
      "家庭成员失业人数\n",
      "庭\n",
      "情\n",
      "1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低\n",
      "况\n",
      "受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职\n",
      "工子女12.家庭经济困难残疾学生13.残疾人子女\n",
      "如符合上述类型，请填写相应数字：—\n",
      "与学生\n",
      "工作（学习）\n",
      "年收入\n",
      "姓名\n",
      "年龄\n",
      "从业情况\n",
      "文化程度\n",
      "健康状况\n",
      "关系\n",
      "单位\n",
      "（元）\n",
      "主要家庭成员情况\n",
      "黄平\n",
      "文亲\n",
      "建筑2人\n",
      "初中\n",
      "般\n",
      "51\n",
      "1To00\n",
      "列蓉\n",
      "母亲\n",
      "长期\n",
      "初中\n",
      "银行柜员\n",
      "良好\n",
      "49\n",
      "1(4000\n",
      "黄国荣\n",
      "祖文\n",
      "无\n",
      "元\n",
      "小\n",
      "78\n",
      "一般\n",
      "洗水\n",
      "。家庭遭受突发意外事件：\n",
      "家庭遭受自然灾害情况：\n",
      "影响\n",
      "家庭成员因残疾、年迈而劳动能力弱情况：祖文年迈\n",
      "家庭\n",
      "经济\n",
      "。家庭欠债情况：久债20元\n",
      "状况\n",
      "有关\n",
      "其他情况：\n",
      "信息\n",
      "承诺内容：\n",
      "内客属实\n",
      "个人承诺\n",
      "街道办或村委会联系\n",
      "0791-81721344\n",
      "电话 (必填)\n",
      "学生本人签名：ho\n",
      "[2024/07/31 15:36:41] ppocr DEBUG: dt_boxes num : 106, elapsed : 0.6886801719665527\n",
      "[2024/07/31 15:36:42] ppocr DEBUG: cls num  : 106, elapsed : 0.1670372486114502\n",
      "[2024/07/31 15:36:44] ppocr DEBUG: rec_res num  : 106, elapsed : 2.4140326976776123\n",
      "附件：\n",
      "华南理工大学家庭经济困难本科生认定申请表\n",
      "院系：外国治业：\n",
      "英语\n",
      "年级：\n",
      "大二班级：13\n",
      "学号：2017009876\n",
      "姓名\n",
      "五伟\n",
      "性别\n",
      "男\n",
      "出生年月\n",
      "1999.10民族\n",
      "汉\n",
      "身份证\n",
      "户口\n",
      "口城镇\n",
      "农村\n",
      "号码5101011991015234\n",
      "性质\n",
      "户籍地址\n",
      "家长手机号码\n",
      "13900139003\n",
      "家庭人均年收入\n",
      "（元）\n",
      "40000\n",
      "家庭人口数\n",
      "家庭成员在学人数\n",
      "4\n",
      "家\n",
      "赠养人数\n",
      "家庭成员失业人数\n",
      "庭\n",
      "情\n",
      "况\n",
      "受国家定期抚恤补贴的优抚对象(含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职\n",
      "工子女12.家庭经济困难残疾学生13.残疾人子女\n",
      "如符合上述类型，请填写相应数字：\n",
      "6\n",
      "与学生\n",
      "工作（学习）\n",
      "年收入\n",
      "姓名\n",
      "年龄\n",
      "从业情况\n",
      "文化程度\n",
      "健康状况\n",
      "关系\n",
      "单位\n",
      "（元）\n",
      "主要家庭成员情况\n",
      "建筑工人\n",
      "王强\n",
      "文亲\n",
      "稳之\n",
      "高中\n",
      "53\n",
      "39000\n",
      "般\n",
      "李娇\n",
      "5。\n",
      "教师\n",
      "长期\n",
      "大专\n",
      "民好\n",
      "41000\n",
      "王国院\n",
      "80\n",
      "祖父\n",
      "无\n",
      "初中\n",
      "差\n",
      "家庭遭受自然灾害情况：\n",
      "一。家庭遭受突发意外事件：祖文病年\n",
      "影响\n",
      "家庭\n",
      "家庭成员因残疾、年迈而劳动能力弱情况：_祖文年五\n",
      "经济\n",
      "。家庭欠债情况：人责/000。元\n",
      "家庭成员失业情况：\n",
      "状况\n",
      "有关\n",
      "信息\n",
      "承诺内容：\n",
      "刀\n",
      "街道办或村委会联系\n",
      "人承诺\n",
      "7612346\n",
      "028-1\n",
      "电话（必填）\n",
      "学生本人签名：\n",
      "222年月\n"
     ]
    }
   ],
   "source": [
    "import ollama\n",
    "\n",
    "#处理图片\n",
    "def get_ocr_result(image_path):\n",
    "  result = ocr.ocr(image_path, cls=True)\n",
    "  ocr_result = \"\"\n",
    "  for idx in range(len(result)):\n",
    "      res = result[idx]\n",
    "      for line in res:\n",
    "          print(line[1][0])\n",
    "          # ocr_result = ocr_result + \" \" + str(line)\n",
    "          ocr_result = ocr_result + \" \" + str(line[1][0])\n",
    "  #         break\n",
    "  return ocr_result\n",
    "\n",
    "# 流式输出\n",
    "def api_generate(text:str):\n",
    "  print(f'{text}')\n",
    " \n",
    "  stream = ollama.generate(\n",
    "    stream=True,\n",
    "    # model='qwen2:1.5b',\n",
    "    model='qwen2',\n",
    "    system=\"\"\"你十分善于提取关键信息并且总结为json格式\"\"\",\n",
    "    prompt=text,\n",
    "    # 指定上下文长度\n",
    "    options={'num_ctx':8000}\n",
    "    )\n",
    " \n",
    "  print('-----------------------------------------')\n",
    "  for chunk in stream:\n",
    "    if not chunk['done']:\n",
    "      print(chunk['response'], end='', flush=True)\n",
    "    else:\n",
    "      print('\\n')\n",
    "      print('-----------------------------------------')\n",
    "    #   print(f'总耗时：{chunk['total_duration']}')\n",
    "      print('-----------------------------------------')\n",
    " \n",
    "\n",
    "ocr_result3=get_ocr_result('image/a83.jpg')\n",
    "ocr_result4=get_ocr_result('image/a84.jpg')\n",
    "ocr_result5=get_ocr_result('image/a85.jpg')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1+1\n",
      "-----------------------------------------\n",
      "{\n",
      "  \"calculation\": {\n",
      "    \"operation\": \"+\",\n",
      "    \"operands\": [1, 1],\n",
      "    \"result\": 2\n",
      "  }\n",
      "}\n",
      "\n",
      "-----------------------------------------\n",
      "-----------------------------------------\n",
      "{'model': 'qwen2', 'created_at': '2024-07-31T07:38:10.3721116Z', 'response': '天空之所以呈现蓝色，主要与光的散射现象有关。地球的大气层包含许多微小的粒子，如氮、氧分子以及尘埃颗粒等。当太阳光进入地球大气时，它会与这些粒子相互作用。\\n\\n光线是由不同波长组成的电磁辐射，太阳发出的光包含了从红色到紫色的所有颜色。不同颜色的光具有不同的波长和频率：红色光的波长较长，而蓝色光的波长较短。在散射过程中，由于蓝光的波长短、能量高，在与大气粒子相互作用时更容易被分散或散射。\\n\\n当太阳光进入大气层时，它会遇到空气分子以及其它微粒，并在这些点上发生随机方向上的散射。这个过程称为瑞利散射。蓝光的能量较高，使得其在遇到大气中的分子时更倾向于向各个方向散射。因此，在整个天空中，从不同角度观察到的光线大部分是蓝色光。\\n\\n当我们在白天仰望天空时，我们看到的是来自太阳的所有颜色经过大气层后，蓝色光散射进入我们的眼睛最多，所以天空呈现出蓝色。此外，在日出和日落时，由于阳光需要穿过更多的大气才能到达地面，蓝光被进一步分散，而波长较长的红、橙色光线则更容易穿透，因此我们在日出和日落时看到的是更温暖色调的天空。\\n\\n总之，天空呈现蓝色是因为空气分子对太阳光中的蓝光进行更多次的随机散射，使得我们从地面观察到的大部分天空颜色为蓝色。', 'done': True, 'done_reason': 'stop', 'context': [151644, 872, 198, 101916, 100678, 20412, 105681, 9370, 11319, 151645, 198, 151644, 77091, 198, 101916, 105133, 104401, 105681, 3837, 99558, 57218, 99225, 9370, 99632, 99759, 102060, 101063, 1773, 102493, 104197, 99180, 99371, 102298, 100694, 48934, 30709, 9370, 117184, 3837, 29524, 109958, 5373, 100316, 102388, 101034, 100498, 101499, 107561, 49567, 1773, 39165, 101281, 99225, 101040, 102493, 105797, 13343, 3837, 99652, 36993, 57218, 100001, 117184, 104225, 100154, 3407, 109587, 104625, 99604, 99804, 45861, 107339, 110314, 105357, 3837, 101281, 104351, 9370, 99225, 115191, 45181, 104165, 26939, 111413, 105679, 102284, 1773, 99604, 102284, 9370, 99225, 100629, 101970, 99804, 45861, 33108, 107586, 5122, 104165, 99225, 9370, 99804, 45861, 112228, 3837, 68536, 105681, 99225, 9370, 99804, 45861, 99260, 99534, 1773, 18493, 99632, 99759, 101925, 3837, 101887, 100400, 99225, 9370, 99804, 116464, 5373, 101426, 44636, 96050, 57218, 105797, 117184, 104225, 100154, 13343, 108478, 99250, 105211, 57191, 99632, 99759, 3407, 39165, 101281, 99225, 101040, 105797, 99371, 13343, 3837, 99652, 36993, 104011, 100819, 102388, 101034, 102158, 48934, 101425, 90395, 18493, 100001, 27442, 17447, 99726, 107898, 100696, 101913, 99632, 99759, 1773, 99487, 100178, 102424, 100705, 59532, 99632, 99759, 1773, 100400, 99225, 111341, 105540, 3837, 104193, 41146, 18493, 104011, 105797, 101047, 102388, 13343, 33126, 114587, 69041, 101284, 100696, 99632, 99759, 1773, 101886, 96050, 101908, 101916, 15946, 3837, 45181, 99604, 100884, 104144, 26939, 9370, 109587, 101212, 20412, 105681, 99225, 3407, 39165, 104952, 106772, 102690, 99317, 101916, 13343, 3837, 97639, 101038, 100146, 101919, 101281, 105679, 102284, 101897, 105797, 99371, 33447, 3837, 105681, 99225, 99632, 99759, 101040, 97639, 106975, 102538, 3837, 99999, 101916, 107433, 105681, 1773, 104043, 96050, 8903, 20221, 33108, 8903, 99297, 13343, 3837, 101887, 104166, 85106, 109239, 102075, 105797, 101901, 104658, 104722, 3837, 100400, 99225, 99250, 100642, 105211, 3837, 68536, 99804, 45861, 112228, 9370, 99425, 5373, 107678, 38035, 109587, 46448, 108478, 116725, 3837, 101886, 104952, 8903, 20221, 33108, 8903, 99297, 13343, 101038, 100146, 33126, 104607, 113215, 9370, 101916, 3407, 106279, 3837, 101916, 104401, 105681, 20412, 62112, 50647, 99180, 102388, 32664, 101281, 99225, 101047, 100400, 99225, 71817, 99573, 32571, 9370, 107898, 99632, 99759, 3837, 104193, 97639, 45181, 104722, 104144, 26939, 9370, 101212, 101916, 102284, 17714, 105681, 1773], 'total_duration': 67637593100, 'load_duration': 8589323900, 'prompt_eval_count': 14, 'prompt_eval_duration': 1243928000, 'eval_count': 331, 'eval_duration': 57648691000}\n"
     ]
    }
   ],
   "source": [
    "## 示例测试\n",
    "\n",
    "key='院系, 专业, 年级, 班级, 学号, 姓名, 性别, 出生年月, 民族, 主要家庭成员情况,日期'\n",
    "# 流式输出\n",
    "api_generate(text='1+1')\n",
    "\n",
    "# 非流式输出\n",
    "content = ollama.generate(model='qwen2', prompt='天空为什么是蓝色的？')\n",
    "print(content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你现在的任务是从OCR文字识别的结果中提取我指定的关键信息。OCR的文字识别结果使用```符号包围，包含所识别出来的文字，\n",
      "            顺序在原始图片中从左至右、从上至下。我指定的关键信息使用[]符号包围。请注意OCR的文字识别结果可能存在长句子换行被切断、不合理的分词、\n",
      "            对应错位等问题，你需要结合上下文语义进行综合判断，以抽取准确的关键信息。输出为json格式。\n",
      "            下面正式开始：\n",
      "            OCR文字：``` 7788.com Z57A001950 杭州东售 2013年07月07日13:39开 06车12B号 二等座 G7512次 杭州东 上海虹桥 HangZhouDong ShangHaiHongQiao ￥73.00元 限乘当日当次车 余友红 检票口16 3623301993****0941 9004-1300-5707-08A0-0195-0 和谐号 CanonPowerShotA3400 ISF2.8 1/20s IS0400```\n",
      "            要抽取的关键信息：[名字 时间]。\n",
      "-----------------------------------------\n",
      "```json\n",
      "{\n",
      "  \"name\": \"余友红\",\n",
      "  \"time\": \"2013年07月07日13:39\"\n",
      "}\n",
      "```\n",
      "\n",
      "-----------------------------------------\n",
      "-----------------------------------------\n"
     ]
    }
   ],
   "source": [
    "## 示例测试\n",
    "\n",
    "\n",
    "key = \"名字 时间\"\n",
    "ocr_result= ' 7788.com Z57A001950 杭州东售 2013年07月07日13:39开 06车12B号 二等座 G7512次 杭州东 上海虹桥 HangZhouDong ShangHaiHongQiao ￥73.00元 限乘当日当次车 余友红 检票口16 3623301993****0941 9004-1300-5707-08A0-0195-0 和谐号 CanonPowerShotA3400 ISF2.8 1/20s IS0400'\n",
    "prompt = f\"\"\"你现在的任务是从OCR文字识别的结果中提取我指定的关键信息。OCR的文字识别结果使用```符号包围，包含所识别出来的文字，\n",
    "            顺序在原始图片中从左至右、从上至下。我指定的关键信息使用[]符号包围。请注意OCR的文字识别结果可能存在长句子换行被切断、不合理的分词、\n",
    "            对应错位等问题，你需要结合上下文语义进行综合判断，以抽取准确的关键信息。输出为json格式。\n",
    "            下面正式开始：\n",
    "            OCR文字：```{ocr_result}```\n",
    "            要抽取的关键信息：[{key}]。\"\"\"\n",
    "api_generate(text=prompt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你现在的任务是从OCR文字识别的结果中提取我指定的关键信息。OCR的文字识别结果使用```符号包围，包含所识别出来的文字，顺序在原始图片中从左至右、从上至下。我指定的关键信息使用[]符号包围。请注意OCR的文字识别结果可能存在长句子换行被切断、不合理的分词、\n",
      "            对应错位等问题，你需要结合上下文语义进行综合判断，以抽取准确的关键信息。输出为json格式。让我们逐步思考。\n",
      "            下面正式开始：\n",
      "            OCR文字：``` 附件： 华南理工大学家庭经济困难本科生认定申请表 院系：物理专业： 物2里年级：2022班级： 学号：202204347298 姓名霍斤 性别勇 出生年月 2004108 民族 汉 茶 城镇口农村 性质 户籍地址 东省(自治区)小市海(市、区) 镇（街道） 村（居委） 家长手机号码 14290482098 家庭人均年收入 （元） 家庭人口数 Z 家庭成员在学人数 家 庭 赠养人数 家庭成员失业人数 情 1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低 况 生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享 受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职 工子女12.家庭经济困难残疾学生13.残疾人子女 如符合上述类型，请填写相应数字： 与学生 工作（学习） 年收入 姓名 年龄 从业情况 文化程度 健康状况 主要家庭成员情况 关系 单位 （元） 霍久 仅子 服务员 中学 57 5000 无 无 家庭遭受自然灾害情况： 家庭遭受突发意外事件： 影响 霍斤得了期怕金标症 家庭 家庭成员因残疾、年迈而劳动能力弱情况： 经济 元 5万元 家庭成员失业情况： ，家庭欠债情况： 状况 无 有关 其他情况： 信息 承诺内容： 求所信属实 个人承诺 街道办或村委会联系 17320982077 电话（必填） 学生本人签名：霍斤 2024年04月21日```\n",
      "            要抽取的关键信息：[院系, 专业, 年级, 班级, 学号, 姓名, 性别, 出生年月, 民族, 主要家庭成员情况,日期]。\n",
      "-----------------------------------------\n",
      "```json\n",
      "{\n",
      "  \"院系\": \"物理\",\n",
      "  \"专业\": null,\n",
      "  \"年级\": \"2022\",\n",
      "  \"班级\": null,\n",
      "  \"学号\": \"202204347298\",\n",
      "  \"姓名\": \"霍斤\",\n",
      "  \"性别\": \"勇\",\n",
      "  \"出生年月\": \"2004108\",\n",
      "  \"民族\": \"汉\",\n",
      "  \"主要家庭成员情况\": null,\n",
      "  \"日期\": \"2024年04月21日\"\n",
      "}\n",
      "```\n",
      "\n",
      "-----------------------------------------\n",
      "-----------------------------------------\n"
     ]
    }
   ],
   "source": [
    "## 示例测试\n",
    "\n",
    "key='院系, 专业, 年级, 班级, 学号, 姓名, 性别, 出生年月, 民族, 主要家庭成员情况,日期'\n",
    "ocr_result=' 附件： 华南理工大学家庭经济困难本科生认定申请表 院系：物理专业： 物2里年级：2022班级： 学号：202204347298 姓名霍斤 性别勇 出生年月 2004108 民族 汉 茶 城镇口农村 性质 户籍地址 东省(自治区)小市海(市、区) 镇（街道） 村（居委） 家长手机号码 14290482098 家庭人均年收入 （元） 家庭人口数 Z 家庭成员在学人数 家 庭 赠养人数 家庭成员失业人数 情 1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低 况 生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享 受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职 工子女12.家庭经济困难残疾学生13.残疾人子女 如符合上述类型，请填写相应数字： 与学生 工作（学习） 年收入 姓名 年龄 从业情况 文化程度 健康状况 主要家庭成员情况 关系 单位 （元） 霍久 仅子 服务员 中学 57 5000 无 无 家庭遭受自然灾害情况： 家庭遭受突发意外事件： 影响 霍斤得了期怕金标症 家庭 家庭成员因残疾、年迈而劳动能力弱情况： 经济 元 5万元 家庭成员失业情况： ，家庭欠债情况： 状况 无 有关 其他情况： 信息 承诺内容： 求所信属实 个人承诺 街道办或村委会联系 17320982077 电话（必填） 学生本人签名：霍斤 2024年04月21日'\n",
    "\n",
    "prompt = f\"\"\"你现在的任务是从OCR文字识别的结果中提取我指定的关键信息。OCR的文字识别结果使用```符号包围，包含所识别出来的文字，顺序在原始图片中从左至右、从上至下。我指定的关键信息使用[]符号包围。请注意OCR的文字识别结果可能存在长句子换行被切断、不合理的分词、\n",
    "            对应错位等问题，你需要结合上下文语义进行综合判断，以抽取准确的关键信息。输出为json格式。让我们逐步思考。\n",
    "            下面正式开始：\n",
    "            OCR文字：```{ocr_result}```\n",
    "            要抽取的关键信息：[{key}]。\"\"\"\n",
    "api_generate(text=prompt)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "format_json=\"\"\"\n",
    "{\n",
    "    \"表名\": \"\",\n",
    "    \"院系\": \"\",\n",
    "    \"专业\": \"\",\n",
    "    \"年级\": \"\",\n",
    "    \"班级\": \"\",\n",
    "    \"学号\": \"\",\n",
    "    \"基本情况\": [\n",
    "        \"姓名\": \"\",\n",
    "        \"性别\": \"\",\n",
    "        \"出生年月\": \"\",\n",
    "        \"民族\": \"\",\n",
    "        \"身份证号码\": \"\"\n",
    "    ],\n",
    "    \"家庭情况\": [\n",
    "        \"户籍地址\": \"\",\n",
    "        \"家长手机号码\": \"\",\n",
    "        \"家庭人均年收入\": \"\",\n",
    "        \"家庭人口数\": \"\",\n",
    "        \"家庭成员在学人数\": \"\",\n",
    "        \"赡养人数\": \"\",\n",
    "        \"家庭成员失业人数\": \"\",\n",
    "        \"家庭背景\": \"\"\n",
    "    ],\n",
    "    \"家庭成员情况\": [\n",
    "        {\n",
    "            \"姓名\": \"\",\n",
    "            \"年龄\": \"\",\n",
    "            \"与学生关系\": \"\",\n",
    "            \"工作学习单位\": \"\",\n",
    "            \"从业情况\": \"\",\n",
    "            \"文化程度\": \"\",\n",
    "            \"年收入\": \"\",\n",
    "            \"健康状况\": \"\"\n",
    "        },\n",
    "        {\n",
    "            \"姓名\": \"\",\n",
    "            \"年龄\": \"\",\n",
    "            \"与学生关系\": \"\",\n",
    "            \"工作学习单位\": \"\",\n",
    "            \"从业情况\": \"\",\n",
    "            \"文化程度\": \"\",\n",
    "            \"年收入\": \"\",\n",
    "            \"健康状况\": \"\"\n",
    "        }\n",
    "    ],\n",
    "    \"影响家庭经济状况有关信息\": [\n",
    "        \"家庭遭受自然灾害情况\": \"\",\n",
    "        \"家庭遭受突发意外事件\": \"\",\n",
    "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"\",\n",
    "        \"家庭成员失业情况\": \"\",\n",
    "        \"家庭欠债情况\": \"\",\n",
    "        \"其他情况\": \"\"\n",
    "    ]\n",
    "}\n",
    "\"\"\"\n",
    "\n",
    "answer3=\"\"\"\n",
    "{\n",
    "    \"表名\": \"华南理工大学家庭经济困难本科生认定申请表\",\n",
    "    \"院系\": \"物理学院\",\n",
    "    \"专业\": \"物理学\",\n",
    "    \"年级\": \"大三\",\n",
    "    \"班级\": \"3班\",\n",
    "    \"学号\": \"2019012345\",\n",
    "    \"基本情况\": [\n",
    "        \"姓名\": \"林浩\",\n",
    "        \"性别\": \"男\",\n",
    "        \"出生年月\": \"2001.5.20\",\n",
    "        \"民族\": \"汉\",\n",
    "        \"身份证号码\": \"450101200105202345\",\n",
    "    ],\n",
    "    \"家庭情况\": [\n",
    "        \"家长手机号码\": \"13700137002\",\n",
    "        \"家庭人均年收入\": \"27000元\",\n",
    "        \"家庭人口数\": \"3\",\n",
    "        \"家庭成员在学人数\": \"1\",\n",
    "        \"赡养人数\": \"0\",\n",
    "        \"家庭成员失业人数\": \"1\",\n",
    "        \"家庭背景\": \"支出型困难家庭学生\",\n",
    "    ],\n",
    "    \"家庭成员情况\": [\n",
    "        {\n",
    "            \"姓名\": \"林安\",\n",
    "            \"年龄\": \"49岁\",\n",
    "            \"与学生关系\": \"父亲\",\n",
    "            \"工作学习单位\": \"农民\",\n",
    "            \"从业情况\": \"打零工\",\n",
    "            \"文化程度\": \"小学\",\n",
    "            \"年收入\": \"27000\",\n",
    "            \"健康状况\": \"一般\"\n",
    "        },\n",
    "        {\n",
    "            \"姓名\": \"张宁\",\n",
    "            \"年龄\": \"47岁\",\n",
    "            \"与学生关系\": \"母亲\",\n",
    "            \"工作学习单位\": \"无\",\n",
    "            \"从业情况\": \"家庭主妇\",\n",
    "            \"文化程度\": \"初中\",\n",
    "            \"年收入\": \"0\",\n",
    "            \"健康状况\": \"良好\"\n",
    "        }\n",
    "    ],\n",
    "    \"影响家庭经济状况有关信息\": [\n",
    "        \"家庭遭受自然灾害情况\": \"台风\",\n",
    "        \"家庭遭受突发意外事件\": \"无\",\n",
    "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"无\",\n",
    "        \"家庭成员失业情况\": \"母亲失业\",\n",
    "        \"家庭欠债情况\": \"欠债20000元\",\n",
    "        \"其他情况\": \"无\"\n",
    "    ]\n",
    "}\n",
    "\"\"\"\n",
    "\n",
    "answer4=\"\"\"\n",
    "{\n",
    "    \"表名\": \"华南理工大学家庭经济困难本科生认定申请表\",\n",
    "    \"院系\": \"教育学院\",\n",
    "    \"专业\": \"小学教育\",\n",
    "    \"年级\": \"大四\",\n",
    "    \"班级\": \"1班\",\n",
    "    \"学号\": \"2018015678\",\n",
    "    \"基本情况\": [\n",
    "        \"姓名\": \"黄丽\",\n",
    "        \"性别\": \"女\",\n",
    "        \"出生年月\": \"2000.2.12\",\n",
    "        \"民族\": \"汉\",\n",
    "        \"身份证号码\": \"360101200002122345\"\n",
    "    ],\n",
    "    \"家庭情况\": [\n",
    "        \"户籍地址\": \"江西省南昌市新建县望城镇望城村\",\n",
    "        \"家长手机号码\": \"13500135002\",\n",
    "        \"家庭人均年收入\": \"14000元\",\n",
    "        \"家庭人口数\": \"4\",\n",
    "        \"家庭成员在学人数\": \"1\",\n",
    "        \"赡养人数\": \"1\",\n",
    "        \"家庭成员失业人数\": \"0\",\n",
    "        \"家庭背景\": \"最低生活保障家庭学生\"\n",
    "    ],\n",
    "    \"家庭成员情况\": [\n",
    "        {\n",
    "            \"姓名\": \"黄平\",\n",
    "            \"年龄\": \"51\",\n",
    "            \"与学生关系\": \"父亲\",\n",
    "            \"工作学习单位\": \"建筑工人\",\n",
    "            \"从业情况\": \"临时工\",\n",
    "            \"文化程度\": \"初中\",\n",
    "            \"年收入\": \"15000\",\n",
    "            \"健康状况\": \"一般\"\n",
    "        },\n",
    "        {\n",
    "            \"姓名\": \"列蓉\",\n",
    "            \"年龄\": \"49\",\n",
    "            \"与学生关系\": \"母亲\",\n",
    "            \"工作学习单位\": \"银行柜员\",\n",
    "            \"从业情况\": \"长期\",\n",
    "            \"文化程度\": \"初中\",\n",
    "            \"年收入\": \"14000\",\n",
    "            \"健康状况\": \"良好\"\n",
    "        },\n",
    "        {\n",
    "            \"姓名\": \"黄国荣\",\n",
    "            \"年龄\": \"78\",\n",
    "            \"与学生关系\": \"祖父\",\n",
    "            \"工作学习单位\": \"建筑工人\",\n",
    "            \"从业情况\": \"无\",\n",
    "            \"文化程度\": \"小学\",\n",
    "            \"年收入\": \"0\",\n",
    "            \"健康状况\": \"一般\"\n",
    "        }\n",
    "    ],\n",
    "    \"影响家庭经济状况有关信息\": [\n",
    "        \"家庭遭受自然灾害情况\": \"洪水\",\n",
    "        \"家庭遭受突发意外事件\": \"无\",\n",
    "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"祖父年迈\",\n",
    "        \"家庭成员失业情况\": \"母亲失业\",\n",
    "        \"家庭欠债情况\": \"欠债20000元\",\n",
    "        \"其他情况\": \"无\"\n",
    "    ]\n",
    "}\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "# Role: OCR信息提取助手\n",
      "\n",
      "    \n",
      "## Profile: \n",
      "- **Language**: 中文\n",
      "- **Description**: 一个专注于从OCR识别结果中提取关键信息的AI助手，具备语义理解能力，能够准确捕捉并提取所需信息。\n",
      "\n",
      "## Background: \n",
      "1.用户需要从OCR文字识别结果中提取特定关键信息，OCR结果可能存在识别错误或格式问题，可能存在长句子换行被切断、不合理的分词、对应错位等问题，需要助手综合上下文进行准确提取并且修改错误的ocr识别字。\n",
      "2.OCR的文字识别结果使用```符号包围,包含所识别出来的文字，顺序在原始图片中从左至右、从上至下。指定的关键信息使用[]符号包围。识别并提取[]中指定的关键信息点。\n",
      "\n",
      "## Goals: \n",
      "确保从OCR识别结果中准确提取用户指定的关键信息，并以JSON格式输出。\n",
      "\n",
      "## Constraints: \n",
      "### Skills: \n",
      "1. 理解OCR识别结果中的语义和结构。\n",
      "2. 准确识别并提取关键信息，即使在存在识别错误的情况下。\n",
      "\n",
      "### Rules: \n",
      "1. 如果OCR结果中没有用户指定的关键信息，输出value应为'null'。\n",
      "2. 输出结果应严格遵循JSON格式。\n",
      "\n",
      "## Workflow: \n",
      "1. 接收OCR识别结果和用户指定的关键信息并且自动修正一些错别字。\n",
      "2. 分析OCR结果，提取关键信息。\n",
      "3. 以JSON格式输出提取结果。具体格式为\n",
      "{\n",
      "    \"表名\": \"\",\n",
      "    \"院系\": \"\",\n",
      "    \"专业\": \"\",\n",
      "    \"年级\": \"\",\n",
      "    \"班级\": \"\",\n",
      "    \"学号\": \"\",\n",
      "    \"基本情况\": [\n",
      "        \"姓名\": \"\",\n",
      "        \"性别\": \"\",\n",
      "        \"出生年月\": \"\",\n",
      "        \"民族\": \"\",\n",
      "        \"身份证号码\": \"\"\n",
      "    ],\n",
      "    \"家庭情况\": [\n",
      "        \"户籍地址\": \"\",\n",
      "        \"家长手机号码\": \"\",\n",
      "        \"家庭人均年收入\": \"\",\n",
      "        \"家庭人口数\": \"\",\n",
      "        \"家庭成员在学人数\": \"\",\n",
      "        \"赡养人数\": \"\",\n",
      "        \"家庭成员失业人数\": \"\",\n",
      "        \"家庭背景\": \"\"\n",
      "    ],\n",
      "    \"家庭成员情况\": [\n",
      "        {\n",
      "            \"姓名\": \"\",\n",
      "            \"年龄\": \"\",\n",
      "            \"与学生关系\": \"\",\n",
      "            \"工作学习单位\": \"\",\n",
      "            \"从业情况\": \"\",\n",
      "            \"文化程度\": \"\",\n",
      "            \"年收入\": \"\",\n",
      "            \"健康状况\": \"\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"\",\n",
      "            \"年龄\": \"\",\n",
      "            \"与学生关系\": \"\",\n",
      "            \"工作学习单位\": \"\",\n",
      "            \"从业情况\": \"\",\n",
      "            \"文化程度\": \"\",\n",
      "            \"年收入\": \"\",\n",
      "            \"健康状况\": \"\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"\",\n",
      "            \"年龄\": \"\",\n",
      "            \"与学生关系\": \"\",\n",
      "            \"工作学习单位\": \"\",\n",
      "            \"从业情况\": \"\",\n",
      "            \"文化程度\": \"\",\n",
      "            \"年收入\": \"\",\n",
      "            \"健康状况\": \"\"\n",
      "        }\n",
      "    ],\n",
      "    \"影响家庭经济状况有关信息\": [\n",
      "        \"家庭遭受自然灾害情况\": \"\",\n",
      "        \"家庭遭受突发意外事件\": \"\",\n",
      "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"\",\n",
      "        \"家庭成员失业情况\": \"\",\n",
      "        \"家庭欠债情况\": \"\",\n",
      "        \"其他情况\": \"\"\n",
      "    ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "## Example: \n",
      "OCR文字：``` 附件： 华南理工大学家庭经济困难本科生认定申请表 院系：生物理部转业：物理学年级：大三班级：33五学号：20101235 姓名 林造 性别 男 出生年月 D001.5. 29 民族 汉 身份证 户口 城镇农村 广西省（自治区）)南宁市青务县（市、区)五合镇（街道）五合村（居 户籍地址 家长手机号码 13700137002 家庭人均年收入 （元） 家庭人口数 家庭成员在学人数 家 赠养人数 家庭成员失业人数 庭 情 1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低 况 生活保障边缘家庭学生6.支出型困难家庭学生7.特困供养学生8.孤儿（含事实无人抚养）9.享 受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职 工子女12.家庭经济困难残疾学生13.残疾人子女 如符合上述类型，请填写相应数字： 与学生 年收入 工作（学习） 年龄 文化程度 姓名 健康状况 从业情况 关系 单位 （元） 主要家庭成员情况 林安 父条 农民 了季工 小学 7000 49 二般 张宁 母年 家庭主妇 无 中 良好 47 D 家庭遭受自然灾害情况： 台风 家庭遭受突发意外事件： 影响 家庭 家庭成员因残疾、年迈而劳动能力弱情况：之 经济 母亲失业 。家庭欠债情况：资20D0元 家庭成员失业情况： 状况 有关 其他情况： 无 信息 承诺内容： 个人承诺 街道办或村委会联系 771-8711243 电话 (必填） 学生本人签名：```\n",
      "要抽取的关键信息：[表名,院系, 专业, 年级, 班级, 学号, 基本情况,家庭情况, 主要家庭成员情况,影响家庭经济状况有关信息,日期]。\n",
      "Answer：\n",
      "{\n",
      "    \"表名\": \"华南理工大学家庭经济困难本科生认定申请表\",\n",
      "    \"院系\": \"物理学院\",\n",
      "    \"专业\": \"物理学\",\n",
      "    \"年级\": \"大三\",\n",
      "    \"班级\": \"3班\",\n",
      "    \"学号\": \"2019012345\",\n",
      "    \"基本情况\": [\n",
      "        \"姓名\": \"林浩\",\n",
      "        \"性别\": \"男\",\n",
      "        \"出生年月\": \"2001.5.20\",\n",
      "        \"民族\": \"汉\",\n",
      "        \"身份证号码\": \"450101200105202345\",\n",
      "    ],\n",
      "    \"家庭情况\": [\n",
      "        \"家长手机号码\": \"13700137002\",\n",
      "        \"家庭人均年收入\": \"27000元\",\n",
      "        \"家庭人口数\": \"3\",\n",
      "        \"家庭成员在学人数\": \"1\",\n",
      "        \"赡养人数\": \"0\",\n",
      "        \"家庭成员失业人数\": \"1\",\n",
      "        \"家庭背景\": \"支出型困难家庭学生\",\n",
      "    ],\n",
      "    \"家庭成员情况\": [\n",
      "        {\n",
      "            \"姓名\": \"林安\",\n",
      "            \"年龄\": \"49岁\",\n",
      "            \"与学生关系\": \"父亲\",\n",
      "            \"工作学习单位\": \"农民\",\n",
      "            \"从业情况\": \"打零工\",\n",
      "            \"文化程度\": \"小学\",\n",
      "            \"年收入\": \"27000\",\n",
      "            \"健康状况\": \"一般\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"张宁\",\n",
      "            \"年龄\": \"47岁\",\n",
      "            \"与学生关系\": \"母亲\",\n",
      "            \"工作学习单位\": \"无\",\n",
      "            \"从业情况\": \"家庭主妇\",\n",
      "            \"文化程度\": \"初中\",\n",
      "            \"年收入\": \"0\",\n",
      "            \"健康状况\": \"良好\"\n",
      "        }\n",
      "    ],\n",
      "    \"影响家庭经济状况有关信息\": [\n",
      "        \"家庭遭受自然灾害情况\": \"台风\",\n",
      "        \"家庭遭受突发意外事件\": \"无\",\n",
      "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"无\",\n",
      "        \"家庭成员失业情况\": \"母亲失业\",\n",
      "        \"家庭欠债情况\": \"欠债20000元\",\n",
      "        \"其他情况\": \"无\"\n",
      "    ]\n",
      "}\n",
      "\n",
      "\n",
      "OCR文字：``` 附件： 华南理工大学家庭经济困难本科生认定申请表 院系：教学转业：小教育年级：大四班级：1学号：201801567 黄丽 性别女 如名 出生年月 民族 2bD02121 汉 身份证 户口 城镇农村 360101/200002/22345 号码 性质 户籍地址 家长手机号码 13500135002 家庭人均年收入 14000 （元） 家庭人口数 家庭成员在学人数 4 家 赠养人数 家庭成员失业人数 庭 情 1.脱贫家庭学生2.脱贫不稳定家庭学生3.边缘易致贫家庭学生4.最低生活保障家庭学生5.最低 况 受国家定期抚恤补贴的优抚对象（含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职 工子女12.家庭经济困难残疾学生13.残疾人子女 如符合上述类型，请填写相应数字：— 与学生 工作（学习） 年收入 姓名 年龄 从业情况 文化程度 健康状况 关系 单位 （元） 主要家庭成员情况 黄平 文亲 建筑2人 初中 般 51 1To00 列蓉 母亲 长期 初中 银行柜员 良好 49 1(4000 黄国荣 祖文 无 元 小 78 一般 洗水 。家庭遭受突发意外事件： 家庭遭受自然灾害情况： 影响 家庭成员因残疾、年迈而劳动能力弱情况：祖文年迈 家庭 经济 。家庭欠债情况：久债20元 状况 有关 其他情况： 信息 承诺内容： 内客属实 个人承诺 街道办或村委会联系 0791-81721344 电话 (必填) 学生本人签名：ho```\n",
      "要抽取的关键信息：[表名,院系, 专业, 年级, 班级, 学号, 基本情况,家庭情况, 主要家庭成员情况,影响家庭经济状况有关信息,日期]。\n",
      "Answer：\n",
      "{\n",
      "    \"表名\": \"华南理工大学家庭经济困难本科生认定申请表\",\n",
      "    \"院系\": \"教育学院\",\n",
      "    \"专业\": \"小学教育\",\n",
      "    \"年级\": \"大四\",\n",
      "    \"班级\": \"1班\",\n",
      "    \"学号\": \"2018015678\",\n",
      "    \"基本情况\": [\n",
      "        \"姓名\": \"黄丽\",\n",
      "        \"性别\": \"女\",\n",
      "        \"出生年月\": \"2000.2.12\",\n",
      "        \"民族\": \"汉\",\n",
      "        \"身份证号码\": \"360101200002122345\"\n",
      "    ],\n",
      "    \"家庭情况\": [\n",
      "        \"户籍地址\": \"江西省南昌市新建县望城镇望城村\",\n",
      "        \"家长手机号码\": \"13500135002\",\n",
      "        \"家庭人均年收入\": \"14000元\",\n",
      "        \"家庭人口数\": \"4\",\n",
      "        \"家庭成员在学人数\": \"1\",\n",
      "        \"赡养人数\": \"1\",\n",
      "        \"家庭成员失业人数\": \"0\",\n",
      "        \"家庭背景\": \"最低生活保障家庭学生\"\n",
      "    ],\n",
      "    \"家庭成员情况\": [\n",
      "        {\n",
      "            \"姓名\": \"黄平\",\n",
      "            \"年龄\": \"51\",\n",
      "            \"与学生关系\": \"父亲\",\n",
      "            \"工作学习单位\": \"建筑工人\",\n",
      "            \"从业情况\": \"临时工\",\n",
      "            \"文化程度\": \"初中\",\n",
      "            \"年收入\": \"15000\",\n",
      "            \"健康状况\": \"一般\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"列蓉\",\n",
      "            \"年龄\": \"49\",\n",
      "            \"与学生关系\": \"母亲\",\n",
      "            \"工作学习单位\": \"银行柜员\",\n",
      "            \"从业情况\": \"长期\",\n",
      "            \"文化程度\": \"初中\",\n",
      "            \"年收入\": \"14000\",\n",
      "            \"健康状况\": \"良好\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"黄国荣\",\n",
      "            \"年龄\": \"78\",\n",
      "            \"与学生关系\": \"祖父\",\n",
      "            \"工作学习单位\": \"建筑工人\",\n",
      "            \"从业情况\": \"无\",\n",
      "            \"文化程度\": \"小学\",\n",
      "            \"年收入\": \"0\",\n",
      "            \"健康状况\": \"一般\"\n",
      "        }\n",
      "    ],\n",
      "    \"影响家庭经济状况有关信息\": [\n",
      "        \"家庭遭受自然灾害情况\": \"洪水\",\n",
      "        \"家庭遭受突发意外事件\": \"无\",\n",
      "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"祖父年迈\",\n",
      "        \"家庭成员失业情况\": \"母亲失业\",\n",
      "        \"家庭欠债情况\": \"欠债20000元\",\n",
      "        \"其他情况\": \"无\"\n",
      "    ]\n",
      "}\n",
      "\n",
      "\n",
      "## Initialization: \n",
      "作为OCR信息提取助手，我将使用中文与用户对话，友好地欢迎用户，并介绍工作流程。让我们一步步思考。\n",
      "\n",
      "## UserInput: \n",
      "OCR文字：``` 附件： 华南理工大学家庭经济困难本科生认定申请表 院系：外国治业： 英语 年级： 大二班级：13 学号：2017009876 姓名 五伟 性别 男 出生年月 1999.10民族 汉 身份证 户口 口城镇 农村 号码5101011991015234 性质 户籍地址 家长手机号码 13900139003 家庭人均年收入 （元） 40000 家庭人口数 家庭成员在学人数 4 家 赠养人数 家庭成员失业人数 庭 情 况 受国家定期抚恤补贴的优抚对象(含烈士子女、牺牲军人子女）10.因公牺牲警察子女11.特困职 工子女12.家庭经济困难残疾学生13.残疾人子女 如符合上述类型，请填写相应数字： 6 与学生 工作（学习） 年收入 姓名 年龄 从业情况 文化程度 健康状况 关系 单位 （元） 主要家庭成员情况 建筑工人 王强 文亲 稳之 高中 53 39000 般 李娇 5。 教师 长期 大专 民好 41000 王国院 80 祖父 无 初中 差 家庭遭受自然灾害情况： 一。家庭遭受突发意外事件：祖文病年 影响 家庭 家庭成员因残疾、年迈而劳动能力弱情况：_祖文年五 经济 。家庭欠债情况：人责/000。元 家庭成员失业情况： 状况 有关 信息 承诺内容： 刀 街道办或村委会联系 人承诺 7612346 028-1 电话（必填） 学生本人签名： 222年月```\n",
      "要抽取的关键信息：[表名,院系, 专业, 年级, 班级, 学号, 基本情况,家庭情况, 主要家庭成员情况,影响家庭经济状况有关信息,日期]。\n",
      "\n",
      "-----------------------------------------\n",
      "{\n",
      "    \"表名\": \"华南理工大学家庭经济困难本科生认定申请表\",\n",
      "    \"院系\": \"外国语言文学学院\",\n",
      "    \"专业\": \"英语\",\n",
      "    \"年级\": \"大二\",\n",
      "    \"班级\": \"13班\",\n",
      "    \"学号\": \"2017009876\",\n",
      "    \"基本情况\": [\n",
      "        \"姓名\": \"五伟\",\n",
      "        \"性别\": \"男\",\n",
      "        \"出生年月\": \"1999.10\",\n",
      "        \"民族\": \"汉\",\n",
      "        \"身份证号码\": \"5101011991015234\"\n",
      "    ],\n",
      "    \"家庭情况\": [\n",
      "        \"家长手机号码\": \"13900139003\",\n",
      "        \"家庭人均年收入\": \"40000元\",\n",
      "        \"家庭人口数\": \"未知\",\n",
      "        \"家庭成员在学人数\": \"未知\",\n",
      "        \"赡养人数\": \"未知\",\n",
      "        \"家庭成员失业人数\": \"未知\"\n",
      "    ],\n",
      "    \"主要家庭成员情况\": [\n",
      "        {\n",
      "            \"姓名\": \"王强\",\n",
      "            \"年龄\": \"未知\",\n",
      "            \"与学生关系\": \"文亲（可能指父母或亲人）\",\n",
      "            \"工作学习单位\": \"建筑工人\",\n",
      "            \"从业情况\": \"未知\",\n",
      "            \"文化程度\": \"高中\",\n",
      "            \"年收入\": \"39000元\",\n",
      "            \"健康状况\": \"一般\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"李娇\",\n",
      "            \"年龄\": \"未知\",\n",
      "            \"与学生关系\": \"可能指另一家庭成员\",\n",
      "            \"工作学习单位\": \"教师\",\n",
      "            \"从业情况\": \"长期\",\n",
      "            \"文化程度\": \"大专\",\n",
      "            \"年收入\": \"41000元\",\n",
      "            \"健康状况\": \"民好（可能为误识，应为“民族”或“民政”，需核实）\"\n",
      "        },\n",
      "        {\n",
      "            \"姓名\": \"王国院\",\n",
      "            \"年龄\": \"80岁\",\n",
      "            \"与学生关系\": \"祖父\",\n",
      "            \"工作学习单位\": \"未知\",\n",
      "            \"从业情况\": \"无\",\n",
      "            \"文化程度\": \"初中\",\n",
      "            \"年收入\": \"无\",\n",
      "            \"健康状况\": \"差\"\n",
      "        }\n",
      "    ],\n",
      "    \"影响家庭经济状况有关信息\": [\n",
      "        \"家庭遭受自然灾害情况\": \"未具体说明\",\n",
      "        \"家庭遭受突发意外事件\": \"祖文病（可能指某位家庭成员患病）\",\n",
      "        \"家庭成员因残疾、年迈而劳动能力弱情况\": \"_祖文年五 经济 （语义不清晰，需确认）\",\n",
      "        \"家庭成员失业情况\": \"未知\",\n",
      "        \"家庭欠债情况\": \"/000元（可能为输入错误或误解，实际未明确提及数额）\",\n",
      "        \"其他情况\": \"无\"\n",
      "    ],\n",
      "    \"日期\": \"222年月\"  （日期信息在文本中不清晰，需要进一步确认）\n",
      "}\n",
      "\n",
      "-----------------------------------------\n",
      "-----------------------------------------\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "key='表名,院系, 专业, 年级, 班级, 学号, 基本情况,家庭情况, 主要家庭成员情况,影响家庭经济状况有关信息,日期'\n",
    "\n",
    "prompt=f\"\"\"\n",
    "# Role: OCR信息提取助手\n",
    "\n",
    "    \n",
    "## Profile: \n",
    "- **Language**: 中文\n",
    "- **Description**: 一个专注于从OCR识别结果中提取关键信息的AI助手，具备语义理解能力，能够准确捕捉并提取所需信息。\n",
    "\n",
    "## Background: \n",
    "1.用户需要从OCR文字识别结果中提取特定关键信息，OCR结果可能存在识别错误或格式问题，可能存在长句子换行被切断、不合理的分词、对应错位等问题，需要助手综合上下文进行准确提取并且修改错误的ocr识别字。\n",
    "2.OCR的文字识别结果使用```符号包围,包含所识别出来的文字，顺序在原始图片中从左至右、从上至下。指定的关键信息使用[]符号包围。识别并提取[]中指定的关键信息点。\n",
    "\n",
    "## Goals: \n",
    "确保从OCR识别结果中准确提取用户指定的关键信息，并以JSON格式输出。\n",
    "\n",
    "## Constraints: \n",
    "### Skills: \n",
    "1. 理解OCR识别结果中的语义和结构。\n",
    "2. 准确识别并提取关键信息，即使在存在识别错误的情况下。\n",
    "\n",
    "### Rules: \n",
    "1. 如果OCR结果中没有用户指定的关键信息，输出value应为'null'。\n",
    "2. 输出结果应严格遵循JSON格式。\n",
    "\n",
    "## Workflow: \n",
    "1. 接收OCR识别结果和用户指定的关键信息并且自动修正一些错别字。\n",
    "2. 分析OCR结果，提取关键信息。\n",
    "3. 以JSON格式输出提取结果。具体格式为{format_json}\n",
    "\n",
    "\n",
    "## Example: \n",
    "OCR文字：```{ocr_result3}```\n",
    "要抽取的关键信息：[{key}]。\n",
    "Answer：{answer3}\n",
    "\n",
    "OCR文字：```{ocr_result4}```\n",
    "要抽取的关键信息：[{key}]。\n",
    "Answer：{answer4}\n",
    "\n",
    "## Initialization: \n",
    "作为OCR信息提取助手，我将使用中文与用户对话，友好地欢迎用户，并介绍工作流程。让我们一步步思考。\n",
    "\n",
    "## UserInput: \n",
    "OCR文字：```{ocr_result5}```\n",
    "要抽取的关键信息：[{key}]。\n",
    "\"\"\"\n",
    "\n",
    "api_generate(prompt)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Ollama",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
